pkg
pkg copied to clipboard
Adding link flags for the static version
Hi,
when I use LDFLAGS=XXX those flags are only applied to the dynamic linking, the pkg-static build doesn't see them.
Example with -fsanitize=cfi (dynamic build has all the options, static build hasn't):
--- pkg ---
cc -o pkg add.o alias.o annotate.o audit.o autoremove.o check.o clean.o config.o create.o delete.o event.o fetch.o globals.o info.o install.o key.o lock.o main.o plugins.o query.o register.o repo.o rquery.o search.o set.o shell.o shlib.o ssh.o stats.o triggers.o update.o updating.o upgrade.o utils.o version.o which.o -Wl,-znow -fsanitize=cfi -fvisibility=hidden -fsanitize-cfi-cross-dso -flto=thin -fno-sanitize-trap=all -fsanitize-recover=all -pie -Wl,-zrelro -fstack-protector-strong -Wl,-Bstatic -Wl,-whole-archive -L/wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.21.2/libpkg -lpkg_flat -Wl,-no-whole-archive -Wl,-Bdynamic -lelf -ljail -lssl -lcrypto -larchive -lbz2 -lz -llzma -lprivatezstd -lm -pthread -lutil -lmd -Wl,--export-dynamic
--- pkg-static ---
cc -o pkg-static add.o alias.o annotate.o audit.o autoremove.o check.o clean.o config.o create.o delete.o event.o fetch.o globals.o info.o install.o key.o lock.o main.o plugins.o query.o register.o repo.o rquery.o search.o set.o shell.o shlib.o ssh.o stats.o triggers.o update.o updating.o upgrade.o utils.o version.o which.o -static -L/wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.21.2/libpkg -lpkg_flat -lelf -ljail -lssl -lcrypto -larchive -lbz2 -lz -llzma -lprivatezstd -lm -pthread -lutil -lmd
--- pkg ---
ld: error: undefined symbol: __cfi_slowpath_diag
>>> referenced by event.c
>>> pkg.lto.event.o:(cleanup_handler.52c52c1eb832dce3a09137c36f3b0e8a.cfi)
>>> referenced by ucl_emitter_utils.c
>>> /wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.21.2/libpkg/pkg.lto.libpkg_flat.a(ucl_emitter_utils.o at 3229650).o:(ucl_elt_string_write_json.cfi)
>>> referenced by ucl_emitter_utils.c
>>> /wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.21.2/libpkg/pkg.lto.libpkg_flat.a(ucl_emitter_utils.o at 3229650).o:(ucl_elt_string_write_json.cfi)
>>> referenced 3030 more times
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [pkg] Error code 1
Bye, Alexander.