* [PATCH 0/2] um: Fix a couple of issues with stub_exe when building with clang
@ 2024-10-16 21:12 Nathan Chancellor
2024-10-16 21:12 ` [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe Nathan Chancellor
2024-10-16 21:12 ` [PATCH 2/2] um: Disable auto variable initialization for stub_exe.c Nathan Chancellor
0 siblings, 2 replies; 6+ messages in thread
From: Nathan Chancellor @ 2024-10-16 21:12 UTC (permalink / raw)
To: Richard Weinberger, Anton Ivanov, Johannes Berg
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, Benjamin Berg,
linux-um, linux-kernel, llvm, patches, Nathan Chancellor
This series fixes a couple of issues I see when building ARCH=um
defconfig with LLVM=1 after commit 32e8eaf263d9 ("um: use execveat to
create userspace MMs") in -next.
This passes my basic build and boot testing with both GCC and clang.
---
Nathan Chancellor (2):
um: Fix passing '-n' to linker for stub_exe
um: Disable auto variable initialization for stub_exe.c
arch/um/kernel/skas/Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
base-commit: 41ab5fe7471ff38d2909d1c93b88197a89c6a00f
change-id: 20241016-uml-fix-stub_exe-clang-cb8047247d3a
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe
2024-10-16 21:12 [PATCH 0/2] um: Fix a couple of issues with stub_exe when building with clang Nathan Chancellor
@ 2024-10-16 21:12 ` Nathan Chancellor
2024-10-17 12:09 ` kernel test robot
2024-10-19 5:06 ` kernel test robot
2024-10-16 21:12 ` [PATCH 2/2] um: Disable auto variable initialization for stub_exe.c Nathan Chancellor
1 sibling, 2 replies; 6+ messages in thread
From: Nathan Chancellor @ 2024-10-16 21:12 UTC (permalink / raw)
To: Richard Weinberger, Anton Ivanov, Johannes Berg
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, Benjamin Berg,
linux-um, linux-kernel, llvm, patches, Nathan Chancellor
When building stub_exe with clang, there is an error because '-n' is not
a recognized flag by the clang driver (which is being used to invoke the
linker):
clang: error: unknown argument: '-n'
'-n' should be passed along to the linker, as it is the short flag for
'--nmagic', so prefix it with '-Wl,'.
Fixes: 32e8eaf263d9 ("um: use execveat to create userspace MMs")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
arch/um/kernel/skas/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
index fbb61968055f44ac8a963d4c7d250e7c6bbbb321..f93db893b8236cf805edd01b41501d51dd8f0a35 100644
--- a/arch/um/kernel/skas/Makefile
+++ b/arch/um/kernel/skas/Makefile
@@ -27,7 +27,7 @@ quiet_cmd_stub_exe = STUB_EXE $@
$(KBUILD_CFLAGS) $(STUB_EXE_LDFLAGS) \
$(filter %.o,$^)
-STUB_EXE_LDFLAGS = -n -static
+STUB_EXE_LDFLAGS = -Wl,-n -static
targets += stub_exe.dbg stub_exe $(stub_exe_objs-y)
--
2.47.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe
2024-10-16 21:12 ` [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe Nathan Chancellor
@ 2024-10-17 12:09 ` kernel test robot
2024-10-17 21:02 ` Nathan Chancellor
2024-10-19 5:06 ` kernel test robot
1 sibling, 1 reply; 6+ messages in thread
From: kernel test robot @ 2024-10-17 12:09 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: llvm, oe-kbuild-all
Hi Nathan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 41ab5fe7471ff38d2909d1c93b88197a89c6a00f]
url: https://github.com/intel-lab-lkp/linux/commits/Nathan-Chancellor/um-Fix-passing-n-to-linker-for-stub_exe/20241017-051439
base: 41ab5fe7471ff38d2909d1c93b88197a89c6a00f
patch link: https://lore.kernel.org/r/20241016-uml-fix-stub_exe-clang-v1-1-3d6381dc5a78%40kernel.org
patch subject: [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe
config: um-defconfig (https://download.01.org/0day-ci/archive/20241017/202410171923.EbeKa7tA-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project bfe84f7085d82d06d61c632a7bad1e692fd159e4)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241017/202410171923.EbeKa7tA-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410171923.EbeKa7tA-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> clang: warning: argument unused during compilation: '-mno-3dnow' [-Wunused-command-line-argument]
/usr/bin/ld: arch/um/kernel/skas/stub_exe.o: in function `_start':
arch/um/kernel/skas/stub_exe.c:83: undefined reference to `memset'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe
2024-10-17 12:09 ` kernel test robot
@ 2024-10-17 21:02 ` Nathan Chancellor
0 siblings, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2024-10-17 21:02 UTC (permalink / raw)
To: kernel test robot; +Cc: llvm, oe-kbuild-all
Thanks for the report!
On Thu, Oct 17, 2024 at 08:09:50PM +0800, kernel test robot wrote:
> Hi Nathan,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on 41ab5fe7471ff38d2909d1c93b88197a89c6a00f]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Nathan-Chancellor/um-Fix-passing-n-to-linker-for-stub_exe/20241017-051439
> base: 41ab5fe7471ff38d2909d1c93b88197a89c6a00f
> patch link: https://lore.kernel.org/r/20241016-uml-fix-stub_exe-clang-v1-1-3d6381dc5a78%40kernel.org
> patch subject: [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe
> config: um-defconfig (https://download.01.org/0day-ci/archive/20241017/202410171923.EbeKa7tA-lkp@intel.com/config)
> compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project bfe84f7085d82d06d61c632a7bad1e692fd159e4)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241017/202410171923.EbeKa7tA-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202410171923.EbeKa7tA-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> >> clang: warning: argument unused during compilation: '-mno-3dnow' [-Wunused-command-line-argument]
> /usr/bin/ld: arch/um/kernel/skas/stub_exe.o: in function `_start':
> arch/um/kernel/skas/stub_exe.c:83: undefined reference to `memset'
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
Technically, this warning also comes from the same patch that my series
fixes because it uses KBUILD_CFLAGS for linking, which may contain flags
that are not used by the compiler or linker driver. In this case, I
think this comes from the fact that '-mno-3dnow' is now a no-op in LLVM
because 3DNOW support is removed, so we could potentially shore up the
flags in arch/um/Makefile.
Regardless, I do not think it should block acceptance of this series.
Cheers,
Nathan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe
2024-10-16 21:12 ` [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe Nathan Chancellor
2024-10-17 12:09 ` kernel test robot
@ 2024-10-19 5:06 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-10-19 5:06 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: llvm, oe-kbuild-all
Hi Nathan,
kernel test robot noticed the following build errors:
[auto build test ERROR on 41ab5fe7471ff38d2909d1c93b88197a89c6a00f]
url: https://github.com/intel-lab-lkp/linux/commits/Nathan-Chancellor/um-Fix-passing-n-to-linker-for-stub_exe/20241017-051439
base: 41ab5fe7471ff38d2909d1c93b88197a89c6a00f
patch link: https://lore.kernel.org/r/20241016-uml-fix-stub_exe-clang-v1-1-3d6381dc5a78%40kernel.org
patch subject: [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe
config: um-randconfig-001-20241017 (https://download.01.org/0day-ci/archive/20241019/202410191242.MebRsSji-lkp@intel.com/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241019/202410191242.MebRsSji-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410191242.MebRsSji-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
>> /usr/bin/ld: warning: arch/um/kernel/skas/stub_exe.dbg has a LOAD segment with RWX permissions
/usr/bin/ld: arch/um/kernel/skas/stub_exe.o: in function `_start':
arch/um/kernel/skas/stub_exe.c:83: undefined reference to `memset'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `fileWriter':
>> InstrProfilingFile.c:(.text.fileWriter+0x44): undefined reference to `fwrite'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.fileWriter+0x83): undefined reference to `fseek'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.fileWriter+0xd0): undefined reference to `fwrite'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `getCurFilenameLength':
>> InstrProfilingFile.c:(.text.getCurFilenameLength+0x2c): undefined reference to `strlen'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilenameLength+0x55): undefined reference to `strlen'
/usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilenameLength+0x64): undefined reference to `strlen'
/usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilenameLength+0x87): undefined reference to `strlen'
/usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilenameLength+0xa8): undefined reference to `strlen'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o):InstrProfilingFile.c:(.text.getCurFilenameLength+0xb7): more undefined references to `strlen' follow
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `getCurFilename':
>> InstrProfilingFile.c:(.text.getCurFilename+0x1c0): undefined reference to `memcpy'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilename+0x23e): undefined reference to `getpid'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilename+0x276): undefined reference to `snprintf'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilename+0x43a): undefined reference to `strlen'
/usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilename+0x455): undefined reference to `strlen'
/usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilename+0x4da): undefined reference to `strlen'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.getCurFilename+0x4eb): undefined reference to `memcpy'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `createProfileDir':
>> InstrProfilingFile.c:(.text.createProfileDir+0xb): undefined reference to `strlen'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.createProfileDir+0x3b): undefined reference to `strncpy'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `truncateCurrentFile':
>> InstrProfilingFile.c:(.text.truncateCurrentFile+0x3f): undefined reference to `getenv'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.truncateCurrentFile+0x64): undefined reference to `setenv'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.truncateCurrentFile+0x85): undefined reference to `fopen'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.truncateCurrentFile+0x92): undefined reference to `fclose'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `getProfileFileSizeForMerging':
>> InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x14): undefined reference to `fseek'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x21): undefined reference to `ftell'
>> /usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x31): undefined reference to `fseek'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x52): undefined reference to `__errno_location'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x59): undefined reference to `strerror'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x6a): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x74): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x82): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0x9a): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0xa1): undefined reference to `__errno_location'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0xa8): undefined reference to `strerror'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0xb9): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.getProfileFileSizeForMerging+0xc3): undefined reference to `fprintf'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `mmapProfileForMerging':
InstrProfilingFile.c:(.text.mmapProfileForMerging+0xd): undefined reference to `fileno'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0x27): undefined reference to `mmap'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0x53): undefined reference to `munmap'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0x5a): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0x72): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0x7e): undefined reference to `__errno_location'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0x85): undefined reference to `strerror'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0x96): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapProfileForMerging+0xa0): undefined reference to `fprintf'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `mmapForContinuousMode.constprop.0.isra.0':
InstrProfilingFile.c:(.text.mmapForContinuousMode.constprop.0.isra.0+0x6c): undefined reference to `fileno'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapForContinuousMode.constprop.0.isra.0+0x88): undefined reference to `mmap'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapForContinuousMode.constprop.0.isra.0+0xd1): undefined reference to `__errno_location'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapForContinuousMode.constprop.0.isra.0+0xd8): undefined reference to `strerror'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapForContinuousMode.constprop.0.isra.0+0xe9): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.mmapForContinuousMode.constprop.0.isra.0+0xff): undefined reference to `fprintf'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `writeFile':
InstrProfilingFile.c:(.text.writeFile+0x45): undefined reference to `free'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x58): undefined reference to `getenv'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0xa4): undefined reference to `fclose'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0xf1): undefined reference to `fileno'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0xfa): undefined reference to `ftruncate'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x10c): undefined reference to `fseek'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x11c): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x121): undefined reference to `__errno_location'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x128): undefined reference to `strerror'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x13f): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x147): undefined reference to `fclose'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x199): undefined reference to `fileno'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x1a3): undefined reference to `ftruncate'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x1b3): undefined reference to `munmap'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x1cb): undefined reference to `strtol'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x1dd): undefined reference to `calloc'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x1f1): undefined reference to `fflush'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x248): undefined reference to `fopen'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x263): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x27b): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.writeFile+0x286): undefined reference to `munmap'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `initializeProfileForContinuousMode':
InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x9c): undefined reference to `fopen'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0xac): undefined reference to `ftell'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0xb4): undefined reference to `getpagesize'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0xe6): undefined reference to `__errno_location'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0xed): undefined reference to `strerror'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x101): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x10b): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x11e): undefined reference to `fclose'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x17e): undefined reference to `munmap'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x1a5): undefined reference to `fclose'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x1e3): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x1fb): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x223): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x237): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x241): undefined reference to `__errno_location'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x248): undefined reference to `strerror'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x25c): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x266): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.initializeProfileForContinuousMode+0x281): undefined reference to `fclose'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `parseAndSetFilename':
InstrProfilingFile.c:(.text.parseAndSetFilename+0x4a): undefined reference to `strcmp'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x5a): undefined reference to `strlen'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x72): undefined reference to `free'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x1a7): undefined reference to `getenv'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x228): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x23c): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x2ba): undefined reference to `getpagesize'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x2d9): undefined reference to `getpid'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x2f6): undefined reference to `snprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x34c): undefined reference to `getenv'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x367): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x37b): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x404): undefined reference to `strlen'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x44a): undefined reference to `free'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x471): undefined reference to `getenv'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x4ae): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x4c6): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x4d4): undefined reference to `strdup'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x4ef): undefined reference to `free'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x510): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x524): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x530): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x544): undefined reference to `fprintf'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x550): undefined reference to `stderr'
/usr/bin/ld: InstrProfilingFile.c:(.text.parseAndSetFilename+0x564): undefined reference to `fprintf'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `lprofCreateBufferIOInternal':
InstrProfilingFile.c:(.text.lprofCreateBufferIOInternal+0x16): undefined reference to `free'
/usr/bin/ld: InstrProfilingFile.c:(.text.lprofCreateBufferIOInternal+0x22): undefined reference to `calloc'
/usr/bin/ld: InstrProfilingFile.c:(.text.lprofCreateBufferIOInternal+0x3e): undefined reference to `calloc'
/usr/bin/ld: /opt/cross/clang-7cbf1a2591/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a(InstrProfilingFile.c.o): in function `__llvm_profile_get_path_prefix':
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] um: Disable auto variable initialization for stub_exe.c
2024-10-16 21:12 [PATCH 0/2] um: Fix a couple of issues with stub_exe when building with clang Nathan Chancellor
2024-10-16 21:12 ` [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe Nathan Chancellor
@ 2024-10-16 21:12 ` Nathan Chancellor
1 sibling, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2024-10-16 21:12 UTC (permalink / raw)
To: Richard Weinberger, Anton Ivanov, Johannes Berg
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, Benjamin Berg,
linux-um, linux-kernel, llvm, patches, Nathan Chancellor
When automatic variable initialization is enabled via
CONFIG_INIT_STACK_ALL_{PATTERN,ZERO}, clang will insert a call to
memset() to initialize an object created with __builtin_alloca(). This
ultimately breaks the build when linking stub_exe because it is a
standalone executable that does not include or link against memset().
ld: arch/um/kernel/skas/stub_exe.o: in function `_start':
arch/um/kernel/skas/stub_exe.c:83:(.ltext+0x15): undefined reference to `memset'
Disable automatic variable initialization for stub_exe.c by passing the
default value of 'uninitialized' to '-ftrivial-auto-var-init', which
avoids generating the call to memset(). This code is small and runs
quickly as it is just designed to set up an environment, so stack
variable initialization is unnecessary overhead for little gain.
Fixes: 32e8eaf263d9 ("um: use execveat to create userspace MMs")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
arch/um/kernel/skas/Makefile | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
index f93db893b8236cf805edd01b41501d51dd8f0a35..f6a219074772283f3c6c6d8d6ccaa8a1cfc24e33 100644
--- a/arch/um/kernel/skas/Makefile
+++ b/arch/um/kernel/skas/Makefile
@@ -39,6 +39,11 @@ targets += stub_exe.dbg stub_exe $(stub_exe_objs-y)
CFLAGS_stub.o := $(CFLAGS_NO_HARDENING)
CFLAGS_stub_exe.o := $(CFLAGS_NO_HARDENING)
+
+# Clang will call memset() from __builtin_alloca() when stack variable
+# initialization is enabled, which is used in stub_exe.c.
+CFLAGS_stub_exe.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized)
+
UNPROFILE_OBJS := stub.o stub_exe.o
KCOV_INSTRUMENT := n
--
2.47.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-19 5:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-16 21:12 [PATCH 0/2] um: Fix a couple of issues with stub_exe when building with clang Nathan Chancellor
2024-10-16 21:12 ` [PATCH 1/2] um: Fix passing '-n' to linker for stub_exe Nathan Chancellor
2024-10-17 12:09 ` kernel test robot
2024-10-17 21:02 ` Nathan Chancellor
2024-10-19 5:06 ` kernel test robot
2024-10-16 21:12 ` [PATCH 2/2] um: Disable auto variable initialization for stub_exe.c Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox