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

[gmp] Fix building for linux x86 #31339

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ports/gmp/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ if(VCPKG_DETECTED_CMAKE_C_COMPILER_ID STREQUAL "MSVC")
elseif(VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
# not exporting asm functions
set(disable_assembly ON)
elseif(VCPKG_TARGET_IS_LINUX AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(ccas "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
vcpkg_list(APPEND OPTIONS "ABI=32")
string(APPEND asmflags " -m32")
Comment on lines +68 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have recently seen/used the same x86 pattern in another port but for Android.

  • Do we really need ABI=32 in addition to -m32?
  • Which other x86 toolchains/triplets will understand -m32?
  • Can we get -m32 from the cmake toolchain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ABI=32 is required, fixes:

configure: error: Oops, mp_limb_t is 32 bits, but the assembler code
in this configuration expects 64 bits.
You appear to have set $CFLAGS, perhaps you also need to tell GMP the
intended ABI, see "ABI and ISA" in the manual.

The -m32 is also necessary, without it, compile of asm fails:

tmp-add_n.s: Assembler messages:
tmp-add_n.s:202: Error: operand type mismatch for `jmp'
make[2]: *** [add_n.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
tmp-sub_n.s: Assembler messages:
tmp-sub_n.s:202: Error: operand type mismatch for `jmp'
make[2]: *** [sub_n.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need asm flags you might want to actually request it from vcpkg_get_cmake_vars.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, vcpkg_cmake_get_vars isn't taking parameters such as LANGUAGES ATM. (And maybe it should be handled gracefully if ASM can't be enabled.)

else()
set(ccas "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion ports/gmp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gmp",
"version": "6.2.1",
"port-version": 17,
"port-version": 18,
"description": "The GNU Multiple Precision Arithmetic Library",
"homepage": "https://gmplib.org",
"license": "LGPL-3.0-only OR GPL-2.0-only",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2870,7 +2870,7 @@
},
"gmp": {
"baseline": "6.2.1",
"port-version": 17
"port-version": 18
},
"gmsh": {
"baseline": "4.9.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/gmp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "efae5abe8271dc5c25bfa47b9cc146a29e02dc05",
"version": "6.2.1",
"port-version": 18
},
{
"git-tree": "82d0d40ea6ffa93a17c696a2c2fac9a436d67958",
"version": "6.2.1",
Expand Down