-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[vcpkg_configure_make] Set the --host parameter in case of Linux #22331
Conversation
cc @Neumann-A |
I see that this is modeled after the macOS section. But it seems to me what is really needed is not compiler name matching but checking |
VCPKG_CROSSCOMPILING is set if the host and the target triplet are different. Let's keep this patch minimal and not dive into a refactoring of the whole vcpkg_configure_make. |
It is already hard to refactor because of too many minimal patches... |
What is your suggestion? |
@dg0yt The current solution is IMHO good. What do you wish to have improved? |
Ping @dg0yt |
TBH I gave up on expecting a clear line in the development of But again:
|
I think the first thing to do here is setup the env variables for programs like CC and stuff for linux/osx (just like windows does). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, does this work when you're using clang?
No, in clang you control the compilation target by command line parameters and not by a prefix:
|
Depends on #22534 |
0bbbb27
to
d835ec2
Compare
Rebased to include #22534 I consider this as done. In the current state this is a fix for a pending issue that effects me, mirroring the solution from other build systems. The discussed changes of the whole solution for all targets towards a streamlined conception is out of scope of this PR. |
# Linux - cross-compiling support | ||
if(VCPKG_TARGET_IS_LINUX) | ||
if (requires_autoconfig AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET) | ||
if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "([^\/]*)-gcc$" AND CMAKE_MATCH_1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining what this regex is doing?
- Why is it specific to gcc?
- Why we know that prefix is going to be the right value for
--host
(compare to elsewhere in this file where we use triplet-derived variables) - Is there any reason we shouldn't just always set
--host
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- can we derive the
--host
parameter fromVCPKG_TARGET_ARCHITECTURE
, somewhat like we do in the macOS case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is in place.
Using VCPKG_TARGET_ARCHITECTURE alone does not work, because the ABI setting is not known here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, thanks @daschuer; I'm happy with it then, but I want to discuss it at the meeting with everyone.
Ping for response. |
…scompile Co-authored-by: nicole mazzuca <[email protected]>
d835ec2
to
04f401d
Compare
Note: |
I agree with @Neumann-A |
I am not sure if the outlined solution is more "correct", because it pretends to be a native build on a foreign host. At least it is explicitly mentioned as an anti-pattern in the autoconf manual:
For now I think this PR is in a merge able state, tested on CI and solving an actual issue. I have no interest to hack around the recommendations of the manual. So I suggest to merge this as it is and postpone the suggested changes to another PR form another contributor. |
Your logic is inverted. That is only the case if the user lied to vcpkg and said host-triplet=target-triplet. As said --host should be passed depending on VCPKG_CROSSCOMPILING.
Disagree. The actual issue is that vcpkg_configure_make is not setting up the compiler from the cmake toolchain for !windows. Having configure figuring it out by a magic prefix is just a hack. |
Not using the host compiler without a prefix is a kind of crosscompile for autotools. In addition, autotools do not fully support changing the compiler via command line options. It requires to edit the files. For instance you cannot use clang, see: In configure you find this code:
so you see, that what you consider as hack is just the counterpart of generating the ac_tool_prefix from cmake, which is highly desired. You need to acknowledge that there is a bunch of tools autotools makes use of with this prefix:
|
I am speaking of env variables like
No it doesn't require it. There are
No its not. Windows does use
I am not generating ac_tool_prefix.... I am just setting Also from #22331 (comment)):
This requires
And? I am just asking to specify them explicitly instead of implicitly. In CMake you already have a toolchain where everything is explicitly set. |
I have no interest to argue this any longer or put more work into it . And I really don't mind how the issue is solved. The solution here is a copy of the OSX solution, it just works and does no break anything. So It is up to you accept this or provide a better solution. Since this is only a 15 lines patch with limited scope you may also consider to merge this and revert this by a refactoring of the whole file this also included OSX. |
After deliberation, we think this is an acceptable incremental improvement pending a full rewrite of the I will also note that users can directly specify the autotools host triplet in their vcpkg triplet file via |
@ras0219-msft I still think this shouldn't have been merged. As you mentioned |
This allows to crosscompile on Linux for all autotools ports.
It set the tool prefix determined by the gcc path, via th --host parameter.
What does your PR fix?
Fixes building libgcrypt[core]:arm-linux and libgpg-error[core]:arm-linux on an x64 build machine.
Without this patch the x64 version of the libs is installed int the arm-linux folder
Which triplets are supported/not supported? Have you updated the CI baseline?
No changed
Does your PR follow the maintainer guide?
Yes
If you have added/updated a port: Have you run
./vcpkg x-add-version --all
and committed the result?