Skip to content

[mpir] Port to vcpkg-make#49799

Merged
BillyONeal merged 5 commits into
microsoft:masterfrom
dg0yt:mpir
Feb 5, 2026
Merged

[mpir] Port to vcpkg-make#49799
BillyONeal merged 5 commits into
microsoft:masterfrom
dg0yt:mpir

Conversation

@dg0yt
Copy link
Copy Markdown
Contributor

@dg0yt dg0yt commented Feb 4, 2026

For #49703.
Works for me for x86-linux cross builds with prefixed tools (CC=i686-linux-gnu-gcc CXX=i686-linux-gnu-g++).

Remarks:

  • Returning to version scheme version. [mpir] Fix download REF and HASH #23330 switched to version-date, but the source code is still from 3.0.0. (I didn't change the REF in order to not change the asset.)
    cf. https://repology.org/project/mpir/versions
  • CI does feature testing of this port, but otherwise skips the port. (Conflict with gmp.)
  • mpir.org is gone, the mailing list is dormant. It is more or less inactive.
    (There are 163 commits and > 1400 changed files since 3.0.0, but most distributions still offer 3.0.0.)

@robbert-ef
Copy link
Copy Markdown
Contributor

Does not work for me, produces the same error. (after fixing the typo in the patch file name)

I'm building using -m32 flag

Getting the following warning

  Unable to determine autotools host triplet for cross-build.  You can set
  the VCPKG_MAKE_HOST_TRIPLET variable for x86-linux.

It builds when I add the following to the x86-linux.cmake triplet:

set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86-linux")

Should the community triplet be updated accordingly?
I dont know if that affects any other ports

@dg0yt
Copy link
Copy Markdown
Contributor Author

dg0yt commented Feb 4, 2026

It builds when I add the following to the x86-linux.cmake triplet:

set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86-linux")

Should the community triplet be updated accordingly? I dont know if that affects any other ports?

You can change your local (overlay) triplet as you need. It affects every autotools port which sees this setting. (You can limit the scope with if(PORT STREQUAL ...).) But IMO it is not the right change for the official triplet.

To help us understand which problem you try to solve, you should share shared(or study) the logs, in particular config.log. For example, my local crossbuild reports

  $ ./../src/428702d56e-fdc197ff0d.clean/configure --host=i686-linux-gnu --build=x86_64-pc-linux-gnu [...]

which is exactly the autotools triplet I normally want. An x86-linux vcpkg host triplet (native) build on an x64 machine reports

  $ ./../src/428702d56e-fdc197ff0d.clean/configure --host=i686-linux-gnu --build=i686-linux-gnu [...]

And -m32 is in CFLAGS in both cases.

@dg0yt
Copy link
Copy Markdown
Contributor Author

dg0yt commented Feb 4, 2026

Actually the answer was already there:

Unable to determine autotools host triplet for cross-build.  You can set
  the VCPKG_MAKE_HOST_TRIPLET variable for x86-linux.

So you are doing a crossbuild with compilers which are not prefixed with the autotools triplet.
If you want to do that, you should use a custom/overlay x86-linux triplet file which provides the desired information (for all autotools ports) with something like

set(VCPKG_MAKE_HOST_TRIPET "--host=i686-linux-gnu")

BillyONeal
BillyONeal previously approved these changes Feb 5, 2026
Copy link
Copy Markdown
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

@robbert-ef
Copy link
Copy Markdown
Contributor

robbert-ef commented Feb 5, 2026

You can change your local (overlay) triplet as you need. It affects every autotools port which sees this setting. (You can limit the scope with if(PORT STREQUAL ...).) But IMO it is not the right change for the official triplet.

To help us understand which problem you try to solve, you should share shared(or study) the logs, in particular config.log. For example, my local crossbuild reports

  $ ./../src/428702d56e-fdc197ff0d.clean/configure --host=i686-linux-gnu --build=x86_64-pc-linux-gnu [...]

which is exactly the autotools triplet I normally want. An x86-linux vcpkg host triplet (native) build on an x64 machine reports

  $ ./../src/428702d56e-fdc197ff0d.clean/configure --host=i686-linux-gnu --build=i686-linux-gnu [...]

And -m32 is in CFLAGS in both cases.

The original problem I try to solve is to compile 32-bit version for mpir.
When I try to install current mpir version with CFLAGS=-m32 on x86-linux triplet:

$ ./../src/428702d56e-def7e839da.clean/configure --disable-silent-rules --enable-gmpcompat [...]

causes build to fail:

mul_1.c: Assembler messages:
mul_1.c:43: Error: invalid instruction suffix for `mul'

When I try to install current mpir version with CFLAGS=-m32 and set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86-linux") on x86-linux triplet:

$ ./../src/428702d56e-def7e839da.clean/configure --host=x86-linux --disable-silent-rules --enable-gmpcompat [...]

It still fails with the same error.

When I try to install fixed mpir version with CFLAGS=-m32 on x86-linux triplet:

$ ./../src/428702d56e-929264dff8.clean/configure --enable-cxx --enable-gmpcompat --with-pic --with-yasm=/usr/bin/yasm CFLAGS=-fPIC -m32 [...]

Fails with the same error

When I try to install fixed mpir version with CFLAGS=-m32 on x86-linux triplet with `set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86-linux"):

$ ./../src/428702d56e-929264dff8.clean/configure --host=x86-linux --build=x86_64-pc-linux-gnu --enable-cxx --enable-gmpcompat --with-pic --with-yasm=/usr/bin/yasm CFLAGS=-fPIC -m32 [...]

Succeeds!

For my understanding, why is adding set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86-linux") to triplets/community/x86-linux.cmake not the right change?
This is also done for the android triplets, for example x86-android.cmake

Copy link
Copy Markdown
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

Thanks!

@BillyONeal BillyONeal merged commit e2860d8 into microsoft:master Feb 5, 2026
17 checks passed
@dg0yt dg0yt deleted the mpir branch February 6, 2026 06:59
@dg0yt
Copy link
Copy Markdown
Contributor Author

dg0yt commented Feb 6, 2026

For my understanding, why is adding set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86-linux") to triplets/community/x86-linux.cmake not the right change?
This is also done for the android triplets, for example x86-android.cmake

The android triplets are for one particular toolchain, the official NDK. The same non-prefixed compiler is used with different flags, so it is not possible to guess --host from the compiler filename. (There used to be "standalone" toolchains with prefixed gcc. The triplets can be regarded as official.)

The linux triplets are used for native builds and for cross builds.

x86-linux isn't a typical autotools triplet. With --host=x86-linux and (implicit) --build=i686-linux-gnu, autotools would treat even native builds as crossbuilds, changing configuration results, subject to the specific configure.

x86 on linux is a special.

  • There are toolchains which with non-prefixed gcc which only take -m32 to produce x86 binaries. (Your case.)
    But the general crosscompiling pattern is to use prefixed compilers, and this is covered without providing VCPKG_MAKE_BUILD_TRIPLET.
  • Most x86 crossbuilds are probably done on x64 machines. They may be able to run the x86 code directly. By specifying --host different from (autodetected) --build, autotools are switched into crosscompiling mode. This may or may not be desired because it affects the results of configure.

So adding VCPKG_MAKE_BUILD_TRIPLET to the official triplet will not only fix mpir for your setup, but it will also change things which work now, and it is likely to break some things.

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

Successfully merging this pull request may close these issues.

3 participants