diff --git a/micro-editor.spec b/micro-editor.spec index ed84d49..d363419 100644 --- a/micro-editor.spec +++ b/micro-editor.spec @@ -53,10 +53,23 @@ tar -xf %{SOURCE1} %build export GOFLAGS="-mod=vendor" +export CGO=0 -%ifnarch ppc64 ppc64le - export GOFLAGS="${GOFLAGS} -buildmode=pie" -%endif +case "$(uname -m)" in + # Enabling PIE (Position Independent Executable) in go allows a binary to be loaded by the OS into a random memory address + # however certain CPU architectures do not support PIEs by default so we have to disable it to properly build on OBS + # We achieve this by disabling PIE in favor of CGO + + # Disable PIE for these architectures + s390x|ppc64|ppc64le|i386|i586|i686|riscv64|armv7l|armv6l) + echo "Building on $(uname -m): PIE disabled (requires CGO)" + ;; + *) + # Enable PIE for x86_64 and aarch64 + echo "Building on $(uname -m): Enabling PIE" + export GOFLAGS="$GOFLAGS -buildmode=pie" + ;; +esac export DATE="$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%s)} --iso-8601)" export HASH="%{shortcommit}"