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

[vcpkg scripts]: Include --build in autoconf xcompile #43703

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 1 addition & 2 deletions ports/vcpkg-make/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "vcpkg-make",
"version-date": "2025-01-13",
"port-version": 1,
"version-date": "2025-02-08",
"documentation": "https://learn.microsoft.com/vcpkg/maintainers/functions/vcpkg_make_configure",
"license": null,
"supports": "native",
Expand Down
41 changes: 38 additions & 3 deletions ports/vcpkg-make/vcpkg_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ endfunction()

function(z_vcpkg_make_get_configure_triplets out)
cmake_parse_arguments(PARSE_ARGV 1 arg
""
"COMPILER_NAME"
"AVOID_BUILD_TRIPLET"
"COMPILER_NAME;CONFIG_DIR"
""
)
z_vcpkg_unparsed_args(FATAL_ERROR)
Expand All @@ -140,7 +140,7 @@ function(z_vcpkg_make_get_configure_triplets out)
set(build_triplet_opt "--build=${BUILD_ARCH}-pc-mingw32")
endif()

set(host_triplet "")
set(host_triplet_opt "")
if(VCPKG_CROSSCOMPILING)
if(VCPKG_TARGET_IS_WINDOWS)
if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32)
Expand All @@ -158,6 +158,41 @@ function(z_vcpkg_make_get_configure_triplets out)
endif()
endif()

if (host_triplet_opt AND NOT build_triplet_opt AND NOT arg_AVOID_BUILD_TRIPLET)
# According to the autoconf manual, when specifying --host, one should always also specify
# --build. It is mentioned that this was due to historic reasons and that it will be fixed
# in some future version but for now, we should do exactly as recommended.
if (arg_CONFIG_DIR)
cmake_path(ABSOLUTE_PATH "config.guess" BASE_DIRECTORY "${arg_CONFIG_DIR}" OUTPUT_VARIABLE config_guess_file)
endif()

if (EXISTS "${config_guess_file}")
if (CMAKE_HOST_WIN32)
vcpkg_execute_required_process(
COMMAND ${base_cmd} -c "${config_guess_file}"
LOGNAME "config.guess-${TARGET_TRIPLET}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BUILD_TRIPLET
)
else()
vcpkg_execute_required_process(
COMMAND "${config_guess_file}"
LOGNAME "config.guess-${TARGET_TRIPLET}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BUILD_TRIPLET
)
endif()

set(build_triplet_opt "--build=${BUILD_TRIPLET}")
elseif (VCPKG_HOST_IS_WINDOWS)
set(build_triplet_opt "--build=${BUILD_ARCH}-pc-mingw32")
elseif (VCPKG_HOST_IS_LINUX)
set(build_triplet_opt "--build=${BUILD_ARCH}-pc-linux")
elseif (VCPKG_HOST_IS_IOS OR VCPKG_HOST_IS_OSX)
set(build_triplet_opt "--build=${BUILD_ARCH}-apple-darwin")
Comment on lines +187 to +192
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet sure whether doing this "estimated guessing" or just leaving it blank would be better. The latter would certainly be more conservative of a change 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

In vcpkg, ports are meant to not build any binary for the host.* (Host binaries must be done via host dependencies,) The guess just needs to be good enough for running the build scripts correctly,

endif()
endif()

set(output "${build_triplet_opt};${host_triplet_opt}")
string(STRIP "${output}" output)
set("${out}" "${output}" PARENT_SCOPE)
Expand Down
7 changes: 4 additions & 3 deletions ports/vcpkg-make/vcpkg_make_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ function(vcpkg_make_configure)
if(DEFINED VCPKG_MAKE_BUILD_TRIPLET)
set(BUILD_TRIPLET "${VCPKG_MAKE_BUILD_TRIPLET}")
endif()
if(NOT DEFINED BUILD_TRIPLET)
z_vcpkg_make_get_configure_triplets(BUILD_TRIPLET COMPILER_NAME "${ccname}")
endif()

if(NOT arg_DISABLE_MSVC_WRAPPERS AND "${frontend}" STREQUAL "MSVC" )
# Lets assume that wrappers are only required for MSVC like frontends.
Expand Down Expand Up @@ -92,6 +89,10 @@ function(vcpkg_make_configure)
set(relative_build_path ".")
endif()

if(NOT DEFINED BUILD_TRIPLET)
z_vcpkg_make_get_configure_triplets(BUILD_TRIPLET COMPILER_NAME "${ccname}" CONFIG_DIR "${target_dir}")
endif()

z_vcpkg_make_prepare_programs(configure_env ${prepare_flags_opts} CONFIG "${configup}" BUILD_TRIPLET "${BUILD_TRIPLET}")

set(opts "")
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -9493,8 +9493,8 @@
"port-version": 0
},
"vcpkg-make": {
"baseline": "2025-01-13",
"port-version": 1
"baseline": "2025-02-08",
"port-version": 0
},
"vcpkg-msbuild": {
"baseline": "2023-08-08",
Expand Down
5 changes: 5 additions & 0 deletions versions/v-/vcpkg-make.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "ff7831101eb4e9e9b3f0d86c2ce2e3e99316b3dc",
"version-date": "2025-02-08",
"port-version": 0
},
{
"git-tree": "276b846fcad524729ffbf6fe1c8b7598cfeac91a",
"version-date": "2025-01-13",
Expand Down
Loading