Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding link flags for the static version #2287

Open
netchild opened this issue May 21, 2024 · 1 comment
Open

Adding link flags for the static version #2287

netchild opened this issue May 21, 2024 · 1 comment

Comments

@netchild
Copy link
Member

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.

@bapt
Copy link
Member

bapt commented May 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants