diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1f8f42482..56f5dfbd82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -238,7 +238,7 @@ jobs: "name": "Linux 32bit", "os": "ubuntu-latest", // Use 32bit on stage0 and stage1 to keep oleans compatible - "CMAKE_OPTIONS": "-DSTAGE0_USE_GMP=OFF -DSTAGE0_LEAN_EXTRA_CXX_FLAGS='-m32' -DSTAGE0_LEANC_OPTS='-m32' -DSTAGE0_MMAP=OFF -DUSE_GMP=OFF -DLEAN_EXTRA_CXX_FLAGS='-m32' -DLEANC_OPTS='-m32' -DMMAP=OFF -DLEAN_INSTALL_SUFFIX=-linux_x86 -DCMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu/ -DSTAGE0_CMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu/", + "CMAKE_OPTIONS": "-DSTAGE0_USE_GMP=OFF -DSTAGE0_LEAN_EXTRA_CXX_FLAGS='-m32' -DSTAGE0_LEANC_OPTS='-m32' -DSTAGE0_MMAP=OFF -DUSE_GMP=OFF -DLEAN_EXTRA_CXX_FLAGS='-m32' -DLEANC_OPTS='-m32' -DMMAP=OFF -DLEAN_INSTALL_SUFFIX=-linux_x86 -DCMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu/ -DSTAGE0_CMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu/ -DPKG_CONFIG_EXECUTABLE=/usr/bin/i386-linux-gnu-pkg-config", "cmultilib": true, "release": true, "check-level": 2, @@ -327,7 +327,7 @@ jobs: run: | sudo dpkg --add-architecture i386 sudo apt-get update - sudo apt-get install -y gcc-multilib g++-multilib ccache libuv1-dev:i386 + sudo apt-get install -y gcc-multilib g++-multilib ccache libuv1-dev:i386 pkgconf:i386 if: matrix.cmultilib - name: Cache uses: actions/cache@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0626f53fc9..5e0c2977bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ foreach(var ${vars}) if("${var}" MATCHES "LLVM*") list(APPEND STAGE0_ARGS "-D${var}=${${var}}") endif() + if("${var}" MATCHES "PKG_CONFIG*") + list(APPEND STAGE0_ARGS "-D${var}=${${var}}") + endif() elseif(("${var}" MATCHES "CMAKE_.*") AND NOT ("${var}" MATCHES "CMAKE_BUILD_TYPE") AND NOT ("${var}" MATCHES "CMAKE_HOME_DIRECTORY")) list(APPEND PLATFORM_ARGS "-D${var}=${${var}}") endif() diff --git a/flake.nix b/flake.nix index 051498340d..372bf8263a 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,7 @@ stdenv = pkgs.overrideCC pkgs.stdenv lean-packages.llvmPackages.clang; } ({ buildInputs = with pkgs; [ - cmake gmp libuv ccache cadical + cmake gmp libuv ccache cadical pkg-config lean-packages.llvmPackages.llvm # llvm-symbolizer for asan/lsan gdb tree # for CI diff --git a/nix/bootstrap.nix b/nix/bootstrap.nix index 3c2b9b9151..c29a902593 100644 --- a/nix/bootstrap.nix +++ b/nix/bootstrap.nix @@ -1,12 +1,12 @@ { src, debug ? false, stage0debug ? false, extraCMakeFlags ? [], - stdenv, lib, cmake, gmp, libuv, cadical, git, gnumake, bash, buildLeanPackage, writeShellScriptBin, runCommand, symlinkJoin, lndir, perl, gnused, darwin, llvmPackages, linkFarmFromDrvs, + stdenv, lib, cmake, pkg-config, gmp, libuv, cadical, git, gnumake, bash, buildLeanPackage, writeShellScriptBin, runCommand, symlinkJoin, lndir, perl, gnused, darwin, llvmPackages, linkFarmFromDrvs, ... } @ args: with builtins; lib.warn "The Nix-based build is deprecated" rec { inherit stdenv; sourceByRegex = p: rs: lib.sourceByRegex p (map (r: "(/src/)?${r}") rs); buildCMake = args: stdenv.mkDerivation ({ - nativeBuildInputs = [ cmake ]; + nativeBuildInputs = [ cmake pkg-config ]; buildInputs = [ gmp libuv llvmPackages.llvm ]; # https://github.com/NixOS/nixpkgs/issues/60919 hardeningDisable = [ "all" ]; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 95eece1747..bf37e32ca9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -295,14 +295,15 @@ index 5e8e0166..f3b29134 100644 PATCH_COMMAND git reset --hard HEAD && printf "${LIBUV_PATCH}" > patch.diff && git apply patch.diff BUILD_IN_SOURCE ON INSTALL_COMMAND "") - set(LIBUV_INCLUDE_DIR "${CMAKE_BINARY_DIR}/libuv/src/libuv/include") - set(LIBUV_LIBRARIES "${CMAKE_BINARY_DIR}/libuv/src/libuv/libuv.a") + set(LIBUV_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/libuv/src/libuv/include") + set(LIBUV_LDFLAGS "${CMAKE_BINARY_DIR}/libuv/src/libuv/libuv.a") else() find_package(LibUV 1.0.0 REQUIRED) endif() -include_directories(${LIBUV_INCLUDE_DIR}) +include_directories(${LIBUV_INCLUDE_DIRS}) if(NOT LEAN_STANDALONE) - string(APPEND LEAN_EXTRA_LINKER_FLAGS " ${LIBUV_LIBRARIES}") + string(JOIN " " LIBUV_LDFLAGS ${LIBUV_LDFLAGS}) + string(APPEND LEAN_EXTRA_LINKER_FLAGS " ${LIBUV_LDFLAGS}") endif() # Windows SDK (for ICU) diff --git a/src/cmake/Modules/FindLibUV.cmake b/src/cmake/Modules/FindLibUV.cmake index 96cebd82bd..e20d1ef010 100644 --- a/src/cmake/Modules/FindLibUV.cmake +++ b/src/cmake/Modules/FindLibUV.cmake @@ -1,12 +1,13 @@ -if (LIBUV_INCLUDE_DIR AND LIBUV_LIBRARIES) +if (LIBUV_FOUND) # Already in cache, be silent set(LIBUV_FIND_QUIETLY TRUE) -endif (LIBUV_INCLUDE_DIR AND LIBUV_LIBRARIES) +endif (LIBUV_FOUND) -find_path(LIBUV_INCLUDE_DIR NAMES uv.h) -find_library(LIBUV_LIBRARIES NAMES uv libuv REQUIRED) -MESSAGE(STATUS "LIBUV: " ${LIBUV_LIBRARIES}) +find_package(PkgConfig REQUIRED) +pkg_search_module(LIBUV REQUIRED libuv) +MESSAGE(STATUS "LIBUV_LDFLAGS: " ${LIBUV_LDFLAGS}) +MESSAGE(STATUS "LIBUV_INCLUDE_DIRS: " ${LIBUV_INCLUDE_DIRS}) include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUV DEFAULT_MSG LIBUV_INCLUDE_DIR LIBUV_LIBRARIES) -mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARIES) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUV DEFAULT_MSG LIBUV_FOUND) +mark_as_advanced(LIBUV_INCLUDE_DIRS LIBUV_LDFLAGS) diff --git a/stage0/src/CMakeLists.txt b/stage0/src/CMakeLists.txt index 95eece1747..bf37e32ca9 100644 --- a/stage0/src/CMakeLists.txt +++ b/stage0/src/CMakeLists.txt @@ -295,14 +295,15 @@ index 5e8e0166..f3b29134 100644 PATCH_COMMAND git reset --hard HEAD && printf "${LIBUV_PATCH}" > patch.diff && git apply patch.diff BUILD_IN_SOURCE ON INSTALL_COMMAND "") - set(LIBUV_INCLUDE_DIR "${CMAKE_BINARY_DIR}/libuv/src/libuv/include") - set(LIBUV_LIBRARIES "${CMAKE_BINARY_DIR}/libuv/src/libuv/libuv.a") + set(LIBUV_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/libuv/src/libuv/include") + set(LIBUV_LDFLAGS "${CMAKE_BINARY_DIR}/libuv/src/libuv/libuv.a") else() find_package(LibUV 1.0.0 REQUIRED) endif() -include_directories(${LIBUV_INCLUDE_DIR}) +include_directories(${LIBUV_INCLUDE_DIRS}) if(NOT LEAN_STANDALONE) - string(APPEND LEAN_EXTRA_LINKER_FLAGS " ${LIBUV_LIBRARIES}") + string(JOIN " " LIBUV_LDFLAGS ${LIBUV_LDFLAGS}) + string(APPEND LEAN_EXTRA_LINKER_FLAGS " ${LIBUV_LDFLAGS}") endif() # Windows SDK (for ICU) diff --git a/stage0/src/cmake/Modules/FindLibUV.cmake b/stage0/src/cmake/Modules/FindLibUV.cmake index 96cebd82bd..e20d1ef010 100644 --- a/stage0/src/cmake/Modules/FindLibUV.cmake +++ b/stage0/src/cmake/Modules/FindLibUV.cmake @@ -1,12 +1,13 @@ -if (LIBUV_INCLUDE_DIR AND LIBUV_LIBRARIES) +if (LIBUV_FOUND) # Already in cache, be silent set(LIBUV_FIND_QUIETLY TRUE) -endif (LIBUV_INCLUDE_DIR AND LIBUV_LIBRARIES) +endif (LIBUV_FOUND) -find_path(LIBUV_INCLUDE_DIR NAMES uv.h) -find_library(LIBUV_LIBRARIES NAMES uv libuv REQUIRED) -MESSAGE(STATUS "LIBUV: " ${LIBUV_LIBRARIES}) +find_package(PkgConfig REQUIRED) +pkg_search_module(LIBUV REQUIRED libuv) +MESSAGE(STATUS "LIBUV_LDFLAGS: " ${LIBUV_LDFLAGS}) +MESSAGE(STATUS "LIBUV_INCLUDE_DIRS: " ${LIBUV_INCLUDE_DIRS}) include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUV DEFAULT_MSG LIBUV_INCLUDE_DIR LIBUV_LIBRARIES) -mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARIES) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUV DEFAULT_MSG LIBUV_FOUND) +mark_as_advanced(LIBUV_INCLUDE_DIRS LIBUV_LDFLAGS)