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_configure_make] Misc fixes #31228

Merged
merged 58 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
78bb1df
Fix lib suffix matching
dg0yt Mar 23, 2023
94bfed4
Preserve flags when transforming standard libs
dg0yt Mar 23, 2023
fc21963
Use separate_arguments
dg0yt Mar 30, 2023
991cf8d
Fix transform
dg0yt Mar 30, 2023
d7bb678
Merge branch 'microsoft:master' into ldflags
dg0yt Apr 5, 2023
1006e38
Merge branch 'microsoft:master' into ldflags
dg0yt Apr 6, 2023
316d39e
Merge branch 'microsoft:master' into ldflags
dg0yt Apr 26, 2023
e3d0270
Merge branch 'microsoft:master' into ldflags
dg0yt Apr 29, 2023
d3afd55
Merge remote-tracking branch 'origin/master' into configure-make-rollup
dg0yt May 3, 2023
26e7924
[vcpkg_configure_make] Fix SKIP_CONFIGURE
dg0yt May 3, 2023
22b4736
Update linker flags
dg0yt May 4, 2023
b83ad8c
Update linker flags
dg0yt May 5, 2023
547b8d7
Fix regex substitution
dg0yt May 5, 2023
cca477e
Restore full CI
dg0yt May 10, 2023
34720ff
Merge remote-tracking branch 'origin/master' into configure-make-rollup
dg0yt May 11, 2023
0015e80
Reuse configure's linker flags setup
dg0yt May 13, 2023
65c2599
Handle ldflags separately from linker flags
dg0yt May 13, 2023
ecd3a0d
Factor out common definitions
dg0yt May 13, 2023
d8293a1
Control docdir and mandir for debug
dg0yt May 13, 2023
efefc8a
Use vcpkg_list APPEND
dg0yt May 13, 2023
ccb18c4
Don't pass -avoid-version into configure
dg0yt May 13, 2023
4f70993
Restore lost escaping
dg0yt May 13, 2023
27446b7
Copy --target from LDFLAGS to CC/CXX
dg0yt May 13, 2023
31a54c3
Consolidate macros into one function
dg0yt May 13, 2023
9369a62
Elaborate ABI flags
dg0yt May 15, 2023
1a8d34e
Elaborate flag processing
dg0yt May 18, 2023
7547fb9
Update warnings for embedded space
dg0yt May 18, 2023
0762e72
Update windows tool path fixup
dg0yt May 18, 2023
0f18276
[libudns] No cross builds
dg0yt May 13, 2023
90734f8
[vcpkg_find_acquire_program] Add VSCLANG
dg0yt May 18, 2023
4d435ba
[gmp] Update CCAS setup
dg0yt May 13, 2023
4240d3a
[nettle] Update CCAS setup
dg0yt May 15, 2023
9ceb749
Fix VSCLANG
dg0yt May 18, 2023
3cb4426
WIP
dg0yt May 18, 2023
0fcaa3e
Restore processing of isysroot
dg0yt May 19, 2023
d5581de
[nettle] Fix assembler option
dg0yt May 19, 2023
f000086
[liburing] Adjust
dg0yt May 19, 2023
9221c09
Variable name changes
dg0yt May 21, 2023
ef09721
Remove redundant separate arguments
dg0yt May 21, 2023
e3c3840
Merge remote-tracking branch 'origin/master' into configure-make-rollup
dg0yt Jun 10, 2023
14043b0
Move -m32/-m64 to ABI flags
dg0yt Jun 10, 2023
36304b8
Unify ABIFLAGS spelling
dg0yt Jun 10, 2023
6cbd138
CI
dg0yt Jun 11, 2023
e4e2ee6
Revert VSCLANG
dg0yt Jun 16, 2023
380413b
Merge remote-tracking branch 'origin/master' into configure-make-rollup
dg0yt Jun 16, 2023
8d09b55
Merge branch 'microsoft:master' into configure-make-rollup
dg0yt Jun 19, 2023
766b636
Merge remote-tracking branch 'origin/master' into configure-make-rollup
dg0yt Jun 27, 2023
6b345b1
Merge remote-tracking branch 'origin/master' into configure-make-rollup
dg0yt Jun 27, 2023
6cd7c74
Use GNU Make to build autotools ports on FreeBSD (microsoft/vcpkg#32282)
SchaichAlonso Jun 28, 2023
9e54255
Merge branch 'microsoft:master' into configure-make-rollup
dg0yt Jul 2, 2023
8579af4
Merge remote-tracking branch 'origin/master' into HEAD
dg0yt Dec 23, 2023
bad5007
Fix flag removal
dg0yt Dec 23, 2023
7d3f3c9
Drop separation of ABI flags
dg0yt Dec 23, 2023
8a64d8b
Handle '-arch=...'
dg0yt Dec 24, 2023
8ff9e76
Revert "Control docdir and mandir for debug"
dg0yt Dec 24, 2023
f8ed916
[icu] Pass uwp option to pkgdata
dg0yt Dec 24, 2023
37108e2
Restore old osx flags hook
dg0yt Dec 25, 2023
aca7914
Add triplet variable to make libtool pass --target to linker
dg0yt Dec 28, 2023
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
1 change: 1 addition & 0 deletions ports/icu/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ elseif(VCPKG_TARGET_IS_UWP)
vcpkg_list(APPEND CONFIGURE_OPTIONS --disable-extras ac_cv_func_tzset=no ac_cv_func__tzset=no)
string(APPEND VCPKG_C_FLAGS " -DU_PLATFORM_HAS_WINUWP_API=1")
string(APPEND VCPKG_CXX_FLAGS " -DU_PLATFORM_HAS_WINUWP_API=1")
vcpkg_list(APPEND BUILD_OPTIONS "PKGDATA_OPTS=--windows-uwp-build -O ../data/icupkg.inc")
elseif(VCPKG_TARGET_IS_OSX AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_list(APPEND CONFIGURE_OPTIONS --enable-rpath)
if(DEFINED CMAKE_INSTALL_NAME_DIR)
Expand Down
1 change: 1 addition & 0 deletions ports/icu/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "icu",
"version": "74.1",
"port-version": 1,
"description": "Mature and widely used Unicode and localization library.",
"homepage": "https://icu.unicode.org/home",
"license": "ICU",
Expand Down
59 changes: 22 additions & 37 deletions scripts/cmake/vcpkg_build_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function(vcpkg_build_make)
#TODO: optimize for install-data (release) and install-exec (release/debug)

else()
if(VCPKG_HOST_IS_OPENBSD)
if(VCPKG_HOST_IS_FREEBSD OR VCPKG_HOST_IS_OPENBSD)
find_program(Z_VCPKG_MAKE gmake REQUIRED)
else()
find_program(Z_VCPKG_MAKE make REQUIRED)
Expand All @@ -70,45 +70,30 @@ function(vcpkg_build_make)
# Since includes are buildtype independent those are setup by vcpkg_configure_make
vcpkg_backup_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH CPPFLAGS CFLAGS CXXFLAGS RCFLAGS)

z_vcpkg_configure_make_common_definitions()

foreach(buildtype IN ITEMS "debug" "release")
if (buildtype STREQUAL "debug" AND _VCPKG_MAKE_NO_DEBUG)
continue()
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "${buildtype}")
if("${buildtype}" STREQUAL "debug")
set(short_buildtype "-dbg")
set(cmake_buildtype "DEBUG")
set(path_suffix "/debug")
else()
# In NO_DEBUG mode, we only use ${TARGET_TRIPLET} directory.
set(short_buildtype "-rel")
set(cmake_buildtype "RELEASE")
set(path_suffix "")
string(TOUPPER "${buildtype}" cmake_buildtype)
set(short_buildtype "${short_name_${cmake_buildtype}}")
set(path_suffix "${path_suffix_${cmake_buildtype}}")

set(working_directory "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_buildtype}/${arg_SUBPATH}")
message(STATUS "Building ${TARGET_TRIPLET}-${short_buildtype}")

if("libtool-link-pass-target" IN_LIST VCPKG_BUILD_MAKE_FIXUP)
# Pass --target to the linker, e.g. for Android
file(GLOB_RECURSE libtool_files "${working_directory}/libtool")
foreach(file IN LISTS libtool_files)
vcpkg_replace_string("${file}" [[-xtarget=*|]] [[-xtarget=*|--target=*|]])
endforeach()
endif()
Comment on lines +87 to 93
Copy link
Contributor

Choose a reason for hiding this comment

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

--target belongs into CC/CXX. libtool doesn't invoke the linker it invokes the linker through the compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is your proposal? Any references?
The compiler which invokes the linker is clang here. --target already is in the LDFLAGS, and it is used this way during configure when libtool is not used. This change makes libtool` pass it through (as passed in). And this is needed to make clang select the right runtime artifacts for Android and the desired API level.

Copy link
Contributor Author

@dg0yt dg0yt Dec 28, 2023

Choose a reason for hiding this comment

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

# Before:
/bin/bash ../libtool  --tag=CC   --mode=link /android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/bin/clang  -g -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mthumb -Wformat -Werror=format-security -fPIC -fno-limit-debug-info -fopenmp  -L/vcpkg/installed/arm-neon-android-dynamic/debug/lib --target=armv7-none-linux-androideabi28 -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments --sysroot=/android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/sysroot -version-info 1:4:0 -o libb2.la -rpath /vcpkg/installed/arm-neon-android-dynamic/debug/lib libb2_la-blake2s-ref.lo libb2_la-blake2b-ref.lo libb2_la-blake2sp.lo libb2_la-blake2bp.lo  -latomic -lm
libtool: link: /android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -shared  -fPIC -DPIC  .libs/libb2_la-blake2s-ref.o .libs/libb2_la-blake2b-ref.o .libs/libb2_la-blake2sp.o .libs/libb2_la-blake2bp.o   -L/vcpkg/installed/arm-neon-android-dynamic/debug/lib -latomic -lm  -g -fstack-protector-strong -mthumb -fopenmp -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined --sysroot=/android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/sysroot   -fopenmp -Wl,-soname -Wl,libb2.so -o .libs/libb2.so
ld.lld: error: cannot open crti.o: No such file or directory
ld.lld: error: cannot open crtbeginS.o: No such file or directory
ld.lld: error: unable to find library -lm
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc_s
ld.lld: error: unable to find library -lpthread
ld.lld: error: unable to find library -lc
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc_s
ld.lld: error: cannot open crtendS.o: No such file or directory
ld.lld: error: cannot open crtn.o: No such file or directory
clang-17: error: linker command failed with exit code 1 (use -v to see invocation)

# After:
/bin/bash ../libtool  --tag=CC   --mode=link /android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/bin/clang  -g -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mthumb -Wformat -Werror=format-security -fPIC -fno-limit-debug-info -fopenmp  -L/vcpkg/installed/arm-neon-android-dynamic/debug/lib --target=armv7-none-linux-androideabi28 -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments --sysroot=/android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/sysroot -version-info 1:4:0 -o libb2.la -rpath /vcpkg/installed/arm-neon-android-dynamic/debug/lib libb2_la-blake2s-ref.lo libb2_la-blake2b-ref.lo libb2_la-blake2sp.lo libb2_la-blake2bp.lo  -latomic -lm
libtool: link: /android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -shared  -fPIC -DPIC  .libs/libb2_la-blake2s-ref.o .libs/libb2_la-blake2b-ref.o .libs/libb2_la-blake2sp.o .libs/libb2_la-blake2bp.o   -L/vcpkg/installed/arm-neon-android-dynamic/debug/lib -latomic -lm  -g -fstack-protector-strong -mthumb -fopenmp --target=armv7-none-linux-androideabi28 -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined --sysroot=/android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/sysroot   -fopenmp -Wl,-soname -Wl,libb2.so -o .libs/libb2.so

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm while searching for the issues i found: wolfSSL/wolfssl#4519

So you should probably use the wrapper script instead of invoking clang directly.
Is there an issue raised with libtool? Seems more like a generic problem with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is also https://debbugs.gnu.org/db/25/25944.html from 2017. So probably just missing somebody who is willing to submit a patch.
I don't think vcpkg should currently correct this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To put things straight, these are the official NDK instructions for autotools:
https://developer.android.com/ndk/guides/other_build_systems#autoconf

So there are prefixed tools. But they are not the tools used in vcpkg's CMake toolchains and forwarded to autotools as implemented in vcpkg_configure_make.

Copy link
Contributor

Choose a reason for hiding this comment

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

So there are prefixed tools. But they are not the tools used in vcpkg's CMake toolchains

Then that should be changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change vcpkg's cmake toolchain setup?
Or transform Android clang --target=x86_64-linux-android32 into x86_64-linux-android32-clang if it exists?
Or simply write a wrapper of that name ourself?

Copy link
Contributor

Choose a reason for hiding this comment

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

transform Android clang --target=x86_64-linux-android32 into x86_64-linux-android32-clang

Change the toolchain to use the wrapper since the wrapper probably needs to be used in more places?
Alternatively, change it to the wrapper in cmake_get_vars?

I don't see a need to generate a wrapper ourself if upstream provides one (but I also already thought about generating wrappers for windows to make sure flags a correctly passed.).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change the toolchain to use the wrapper since the wrapper probably needs to be used in more places?

I'm afraid this is not acceptable because it is not the recommended use of the NDK with CMake. And it would need to deal with different versions of the NDK.

Alternatively, change it to the wrapper in cmake_get_vars?

I'm afraid this is not acceptable because this affects more places, including user ports.


set(working_directory "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${short_buildtype}/${arg_SUBPATH}")
message(STATUS "Building ${TARGET_TRIPLET}${short_buildtype}")
z_vcpkg_configure_make_process_flags("${cmake_buildtype}")

z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags("${cmake_buildtype}")

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(LINKER_FLAGS_${cmake_buildtype} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${cmake_buildtype}}")
else() # dynamic
set(LINKER_FLAGS_${cmake_buildtype} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${cmake_buildtype}}")
endif()
set(LDFLAGS_${cmake_buildtype} "")
if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib")
string(APPEND LDFLAGS_${cmake_buildtype} " -L${Z_VCPKG_INSTALLED}${path_suffix}/lib")
endif()
if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link")
string(APPEND LDFLAGS_${cmake_buildtype} " -L${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link")
endif()
if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe")
set(LINK_ENV_${cmake_buildtype} "$ENV{_LINK_} ${LINKER_FLAGS_${cmake_buildtype}}")
else()
string(APPEND LDFLAGS_${cmake_buildtype} " ${LINKER_FLAGS_${cmake_buildtype}}")
endif()

# Setup environment
set(ENV{CPPFLAGS} "${CPPFLAGS_${cmake_buildtype}}")
set(ENV{CFLAGS} "${CFLAGS_${cmake_buildtype}}")
Expand Down Expand Up @@ -145,31 +130,31 @@ function(vcpkg_build_make)
vcpkg_execute_build_process(
COMMAND ${no_parallel_make_cmd_line}
WORKING_DIRECTORY "${working_directory}"
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}${short_buildtype}"
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}-${short_buildtype}"
)
else()
vcpkg_execute_build_process(
COMMAND ${make_cmd_line}
NO_PARALLEL_COMMAND ${no_parallel_make_cmd_line}
WORKING_DIRECTORY "${working_directory}"
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}${short_buildtype}"
LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}-${short_buildtype}"
)
endif()

file(READ "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}${short_buildtype}-out.log" logdata)
file(READ "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}-${short_buildtype}-out.log" logdata)
if(logdata MATCHES "Warning: linker path does not have real file for library")
message(FATAL_ERROR "libtool could not find a file being linked against!")
endif()

if (arg_ENABLE_INSTALL)
message(STATUS "Installing ${TARGET_TRIPLET}${short_buildtype}")
message(STATUS "Installing ${TARGET_TRIPLET}-${short_buildtype}")
vcpkg_list(SET make_cmd_line ${make_command} ${install_opts})
vcpkg_list(SET no_parallel_make_cmd_line ${make_command} ${no_parallel_install_opts})
vcpkg_execute_build_process(
COMMAND ${make_cmd_line}
NO_PARALLEL_COMMAND ${no_parallel_make_cmd_line}
WORKING_DIRECTORY "${working_directory}"
LOGNAME "install-${TARGET_TRIPLET}${short_buildtype}"
LOGNAME "install-${TARGET_TRIPLET}-${short_buildtype}"
)
endif()

Expand Down
Loading