From: Viktor Szakats Date: Tue, 17 Jun 2025 18:10:28 +0000 (+0200) Subject: cmake: build `stubgss` library for libtests to match autotools X-Git-Tag: curl-8_15_0~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=171b62375965fbf5f02e66f587a83043059ae41a;p=thirdparty%2Fcurl.git cmake: build `stubgss` library for libtests to match autotools Used by test 2056 and 2057, in a way that's Linux- & autotools-specific. This patch builds it for all Unix, syncing cmake with autotools. Adapt the two tests to find the library in CMake builds as well. Tested OK on Linux. (CI does not test this. The corresponding jobs build in debug mode, while the `LD_PRELOAD` feature is locked to non-debug.) On macOS it didn't load without building everything for aarch64e arch: "../bld/tests/libtest/libstubgss.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'arm64e'))" With that fixed it still did not load correctly and/or the tests did not pass. So, for macOS these tests remain disabled. Also: - GHA/macos: build for aarch64e. (recognized by Apple clang as of this patch. llvm and gcc fall back to aarch64.) Follow-up to 56d949d31ad182a22bd3bad25b1a902b635d549d #1687 Closes #17653 --- diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 88ebd647de..2c8ffc9e91 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -238,7 +238,7 @@ jobs: -DCMAKE_INSTALL_PREFIX="$HOME"/curl-install \ -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON \ -DCMAKE_OSX_SYSROOT="${sysroot}" \ - -DCMAKE_C_COMPILER_TARGET="$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \ + -DCMAKE_C_COMPILER_TARGET="$(uname -m | sed 's/arm64/aarch64e/')-apple-darwin$(uname -r)" \ ${MATRIX_GENERATE} ${options} done if [ -d bld_chkprefill ] && ! diff -u bld/lib/curl_config.h bld_chkprefill/lib/curl_config.h; then @@ -460,7 +460,7 @@ jobs: cmake -B bld -G Ninja -D_CURL_PREFILL=ON \ -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON \ -DCMAKE_OSX_SYSROOT="${sysroot}" \ - -DCMAKE_C_COMPILER_TARGET="$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \ + -DCMAKE_C_COMPILER_TARGET="$(uname -m | sed 's/arm64/aarch64e/')-apple-darwin$(uname -r)" \ -DCMAKE_IGNORE_PREFIX_PATH="$(brew --prefix)" \ -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF \ -DCURL_USE_OPENSSL=ON \ diff --git a/tests/data/test2056 b/tests/data/test2056 index 80e592025d..9d9d9db5e2 100644 --- a/tests/data/test2056 +++ b/tests/data/test2056 @@ -43,7 +43,8 @@ ld_preload !Debug -LD_PRELOAD=%PWD/libtest/.libs/libstubgss.so +LD_PRELOAD=libstubgss.so +LD_LIBRARY_PATH=%PWD/libtest/.libs:%PWD/libtest CURL_STUB_GSS_CREDS="KRB5_Alice" diff --git a/tests/data/test2057 b/tests/data/test2057 index 5cbb945901..e86cb0f89c 100644 --- a/tests/data/test2057 +++ b/tests/data/test2057 @@ -59,7 +59,8 @@ ld_preload !Debug -LD_PRELOAD=%PWD/libtest/.libs/libstubgss.so +LD_PRELOAD=libstubgss.so +LD_LIBRARY_PATH=%PWD/libtest/.libs:%PWD/libtest CURL_STUB_GSS_CREDS="NTLM_Alice" diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index f8dedc5c43..597f077313 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -22,7 +22,7 @@ # ########################################################################### -# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, UTILS, CURLX_SRCS, TESTFILES variables +# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, UTILS, CURLX_SRCS, TESTFILES, STUB_GSS variables curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") @@ -60,3 +60,9 @@ target_include_directories(${BUNDLE} PRIVATE set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}") set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_OLDIES" "CURL_DISABLE_DEPRECATION") set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF) + +if(HAVE_GSSAPI AND UNIX) + add_library(stubgss SHARED EXCLUDE_FROM_ALL ${STUB_GSS}) + set_target_properties(stubgss PROPERTIES UNITY_BUILD OFF) + add_dependencies(testdeps stubgss) +endif() diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 46e3ccce79..dced05a7bd 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -40,7 +40,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \ -I$(srcdir) \ -I$(top_srcdir)/tests/unit -# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, UTILS, CURLX_SRCS, TESTFILES variables +# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, UTILS, CURLX_SRCS, TESTFILES, STUB_GSS variables include Makefile.inc EXTRA_DIST = CMakeLists.txt .checksrc $(FIRSTFILES) $(UTILS) $(TESTFILES) \ @@ -79,7 +79,7 @@ if CURL_LT_SHLIB_USE_NO_UNDEFINED libstubgss_la_LDFLAGS += -no-undefined endif libstubgss_la_CFLAGS = $(AM_CFLAGS) -g -libstubgss_la_SOURCES = stub_gssapi.c stub_gssapi.h +libstubgss_la_SOURCES = $(STUB_GSS) libstubgss_la_LIBADD = libstubgss_la_DEPENDENCIES = endif diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index db91fe7c2d..ed61bed29e 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -86,3 +86,5 @@ TESTFILES = \ lib2700.c \ lib3010.c lib3025.c lib3026.c lib3027.c \ lib3100.c lib3101.c lib3102.c lib3103.c lib3104.c lib3105.c lib3207.c lib3208.c + +STUB_GSS = stub_gssapi.c stub_gssapi.h diff --git a/tests/runtests.pl b/tests/runtests.pl index 3f9f80fc20..d644a5e908 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -546,7 +546,7 @@ sub checksystemfeatures { $libcurl = $2; if($curl =~ /linux|bsd|solaris/) { - # system support LD_PRELOAD; may be disabled later + # system supports LD_PRELOAD/LD_LIBRARY_PATH; may be disabled later $feature{"ld_preload"} = 1; } if($curl =~ /win32|Windows|windows|mingw(32|64)/) {