So, I responded and forgot to forward to the list.
Fixing.
Begin forwarded message:
Date: Sun, 10 Apr 2022 18:59:24 -0700
From: stan <upaitag(a)zoho.com>
To: Sérgio Basto <sergio(a)serjux.com>
Subject: Re:
kernel-5.18.0-0.rc1.20220408git1831fed559732b1.20.fc37.src.rpm fails to
build locally
On Sun, 10 Apr 2022 23:06:24 +0100
Sérgio Basto <sergio(a)serjux.com> wrote:
On Sun, 2022-04-10 at 13:35 -0700, stan via kernel wrote:
> /usr/bin/ld: /tmp/cc6wxoxI.o: relocation R_X86_64_32 against
> `.rodata.str1.1' can not be used when making a PIE object; recompile
> with -fPIE
Relocation R_X86_64_PC32 against undefined symbol , usually happens
when LDFLAGS are set with hardening and CFLAGS not . An usually
happens when configure.ac override all system flags with
CFLAGS="something" you need change it to CFLAGS+="something"
https://stackoverflow.com/a/69005262/778517
Thanks. I would never have figured that out. Or, at least it would
have taken a long time.
maybe is an effect of
https://fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck have
you tried %undefine _auto_set_build_flags ?
I'm using the default in the kernel spec, as far as I know. Which
should be the rh flags with all hardening.
+ CFLAGS='-O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall
-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-Wp,-D_GLIBCXX_ASSERTIONS
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-fstack-protector-strong
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1
-Wl,-dT,/home/stan/rpmbuild/BUILD/kernel-5.18-rc1-184-g1831fed559732b1/.package_note-kernel-5.18.0-0.rc1.20220408git1831fed559732b1.20.20220410.fc37.x86_64.ld'
This is a typical compilation stanza from the build:
gcc -Wp,-MMD,arch/x86/realmode/.init.o.d -nostdinc -I./arch/x86/include
-I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi
-I./arch/x86/include/generated/uapi -I./include/uapi
-I./include/generated/uapi -include ./include/linux/compiler-version.h
-include ./include/linux/kconfig.h -include
./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./=
-Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE <-----------
-Werror=implicit-function-declaration -Werror=implicit-int
-Werror=return-type -Wno-format-security -std=gnu11 -mno-sse -mno-mmx
-mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1
-falign-loops=1 -mno-80387 -mno-fp-ret-in-387
-mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic
-mno-red-zone -mcmodel=kernel -Wno-sign-compare
-fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks
-Wno-frame-address -Wno-format-truncation -Wno-format-overflow
-Wno-address-of-packed-member -O2 -fno-allow-store-data-races
-Wframe-larger-than=2048 -fstack-protector-strong
-Wimplicit-fallthrough=5 -Wno-main -Wno-unused-but-set-variable
-Wno-unused-const-variable -fomit-frame-pointer
-ftrivial-auto-var-init=zero -fno-stack-clash-protection
-fzero-call-used-regs=used-gpr -fno-inline-functions-called-once
-Wdeclaration-after-statement -Wvla -Wno-pointer-sign
-Wcast-function-type -Wno-stringop-truncation -Wno-stringop-overflow
-Wno-restrict -Wno-maybe-uninitialized -Wno-alloc-size-larger-than
-fno-strict-overflow -fno-stack-check -fconserve-stack
-Werror=date-time -Werror=incompatible-pointer-types
-Werror=designated-init -Wno-packed-not-aligned
-fplugin=./scripts/gcc-plugins/randomize_layout_plugin.so
-fplugin=./scripts/gcc-plugins/stackleak_plugin.so -DRANDSTRUCT_PLUGIN
-DSTACKLEAK_PLUGIN -fplugin-arg-stackleak_plugin-track-min-size=100
-fplugin-arg-stackleak_plugin-arch=x86
-DKBUILD_MODFILE='"arch/x86/realmode/init"'
-DKBUILD_BASENAME='"init"'
-DKBUILD_MODNAME='"init"' -D__KBUILD_MODNAME=kmod_init -c -o
arch/x86/realmode/init.o arch/x86/realmode/init.c
Could the -fno-PIE be the culprit?