build: build static module archives with PIC#39
Open
ssam18 wants to merge 1 commit into
Open
Conversation
Pass [pic-only] to LT_INIT so libtool emits PIC objects for the `-static` module archives (libdaq_static_afpacket.a and friends). Without this, on Linux toolchains that default to PIE (Ubuntu 22.04+, recent Debian and Fedora), linking those archives into a PIE executable fails with: relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIE Snort 3 with --enable-static-daq is the most common path that hits this. The workaround until now has been to pass CFLAGS=-fPIC at configure time, which is easy to miss. Making PIC the default removes the foot-gun at negligible runtime cost on x86_64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Ubuntu 22.04+ and other distros where the toolchain defaults to PIE executables, linking the libdaq_static_*.a archives into a PIE binary fails with
relocation R_X86_64_32S ... can not be used when making a PIE object. This bites anyone building Snort 3 with--enable-static-daq(the default) against a vanilla./configure && make installof libdaq, and theCFLAGS=-fPICworkaround is easy to miss. Adding[pic-only]toLT_INITtells libtool to emit PIC objects for the static archives by default, same approach libpcap and friends took for the same reason. See snort3/snort3#320.