-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[gmp | mpir] Add --with-pic #25209
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
[gmp | mpir] Add --with-pic #25209
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,12 +19,12 @@ if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX) | |||||||||||||||
| vcpkg_find_acquire_program(YASM) | ||||||||||||||||
|
|
||||||||||||||||
| if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") | ||||||||||||||||
| set(SHARED_STATIC "--enable-static --disable-shared") | ||||||||||||||||
| set(SHARED_STATIC --enable-static --disable-shared --with-pic) | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... usually it's dynamic libs that need PIC, not static. Are you sure you didn't flip the sense here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For non-Windows systems, dynamic libraries require position independent code (aka PIC). On Linux, vcpkg default toolchain, on x86_64, uses static libraries by default: vcpkg/triplets/x64-linux.cmake Lines 1 to 5 in 8e1f46d
But toolchain adds vcpkg/scripts/toolchains/linux.cmake Lines 51 to 52 in 8e1f46d
That means that static libraries will be created, but with position independent code inside. That allows to link those static libraries to shared libraries. The issue #13827 is a bug with GMP or MPIR, because GMP and MPIR have assembler code, to speed-up critical algorithms. That is why GMP and MPIR needs the macro
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PIC is already the default for shared libraries. We can add the option
and that will have the same behavior: both static and dynamic builds will have PIC code.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense 👍. Should we add a comment or something indicating that?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was told that it is a concious decision that vcpkg always uses PIC, even for static triplets, to allow mixing of static and shared libs. It doesn't need to be documented per port. If there is a need to add a comment, it should be in a central location.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dg0yt I don't mean that overall consistency decision, I mean something like:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (To be clear, I'm not saying "please do this", I'm saying "have you considered doing this to stop people's eyebrows from being raised" @lrineau ) |
||||||||||||||||
| else() | ||||||||||||||||
| set(SHARED_STATIC "--disable-static --enable-shared") | ||||||||||||||||
| set(SHARED_STATIC --disable-static --enable-shared) | ||||||||||||||||
| endif() | ||||||||||||||||
|
|
||||||||||||||||
| set(OPTIONS "--disable-silent-rules --enable-gmpcompat --enable-cxx ${SHARED_STATIC}") | ||||||||||||||||
| set(OPTIONS --disable-silent-rules --enable-gmpcompat --enable-cxx ${SHARED_STATIC}) | ||||||||||||||||
|
|
||||||||||||||||
| string(APPEND VCPKG_C_FLAGS " -Wno-implicit-function-declaration") | ||||||||||||||||
| string(APPEND VCPKG_CXX_FLAGS " -Wno-implicit-function-declaration") | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.