Page MenuHomeFreeBSD

Fix building the ia32 vDSO with --no-undefined-version
AbandonedPublic

Authored by val_packett.cool on Feb 5 2023, 4:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 20, 11:08 PM
Unknown Object (File)
Sun, Oct 20, 11:07 PM
Unknown Object (File)
Sun, Oct 20, 11:07 PM
Unknown Object (File)
Sep 24 2024, 1:36 PM
Unknown Object (File)
Sep 24 2024, 1:36 PM
Unknown Object (File)
Sep 24 2024, 1:27 PM
Unknown Object (File)
Sep 7 2024, 4:11 AM
Unknown Object (File)
Jul 29 2024, 3:10 AM
Subscribers

Details

Reviewers
kib
emaste
jrtc27
Group Reviewers
Contributor Reviews (src)
Summary

With an external toolchain that's all LLVM 16 including the binutils,
the build fails because --no-undefined-version became the default in lld:

ld.lld: error: version script assignment of 'FBSD_1.7' to symbol '__vdso_ia32_osigcode' failed: symbol not defined
ld.lld: error: version script assignment of 'FBSD_1.7' to symbol '__vdso_lcall_tramp' failed: symbol not defined

We can preprocess the linker script to fix this.

Sponsored by: https://www.patreon.com/valpackett
Test Plan

My setup for using an all-llvm toolchain is this:

/etc/src.conf:

CROSS_TOOLCHAIN=llvmroot
LLVM_ROOT=/usr/local/llvm16

/usr/local/share/toolchains/llvmroot.mk (I wonder why this file doesn't already exist somewhere… well maybe in the future the llvm16.mk etc. files would include the binutils):

X_COMPILER_TYPE=clang
XCC=${LLVM_ROOT}/bin/clang
XCXX=${LLVM_ROOT}/bin/clang++
XCPP=${LLVM_ROOT}/bin/clang-cpp
XLLVM_LINK=${LLVM_ROOT}/bin/llvm-link
XLD=${LLVM_ROOT}/bin/ld.lld
XAS=${LLVM_ROOT}/bin/llvm-as
XAR=${LLVM_ROOT}/bin/llvm-ar
XNM=${LLVM_ROOT}/bin/llvm-nm
XOBJCOPY=${LLVM_ROOT}/bin/llvm-objcopy
XRANLIB=${LLVM_ROOT}/bin/llvm-ranlib
XSTRINGS=${LLVM_ROOT}/bin/llvm-strings
XSIZE=${LLVM_ROOT}/bin/llvm-size
XSTRIPBIN=${LLVM_ROOT}/bin/llvm-strip

Confirming that the ifdefs happened by seeing the freebsd4 symbol:

$ readelf -a /usr/obj/usr/home/val/base/amd64.amd64/sys/GENERIC/elf-vdso32.so.1

Symbol table '.dynsym' contains 3 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000230     0 NOTYPE  GLOBAL DEFAULT    9 __vdso_ia32_sigcode@@FBSD_1.7 (2)
     2: 0000000000000244     0 NOTYPE  GLOBAL DEFAULT    9 __vdso_freebsd4_ia32_sigcode@@FBSD_1.7 (2)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 49534
Build 46424: arc lint + arc unit

Event Timeline

Did the build failed, or only issued a warning?

I do not think we should preprocess linker script for this issue, PROVIDE-ing the symbols should be enough. At least for me D38392 made the build silent with ld.lld from llvm16.

Yes, it has failed. I wouldn't be that bothered with a little warning :)

Oh, that's an interesting trick! Doesn't seem to be working for me though.

I went with preprocessing because that's what the build system does for everything else (processing the SYMBOL_MAPS in bsd.symver.mk).

btw, what toggles the error is --(no-)undefined-version, no became the default. It seems difficult to make *everything* work with --no-undefined-version, but this was the only thing in the kernel.

val_packett.cool retitled this revision from Fix building the ia32 vDSO with LLVM binutils to Fix building the ia32 vDSO with --no-undefined-version.Feb 6 2023, 6:49 AM
val_packett.cool edited the summary of this revision. (Show Details)

Yes, it has failed. I wouldn't be that bothered with a little warning :)

Oh, that's an interesting trick! Doesn't seem to be working for me though.

I went with preprocessing because that's what the build system does for everything else (processing the SYMBOL_MAPS in bsd.symver.mk).

Yes. and it was unfortunate decision at that time (same as our policy for using symver for userspace).
I updated my review to always define the symbols in .S file instead.