From 6eb806d2c10e0aa872e92829aae59836495922eb Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Tue, 26 Mar 2019 13:50:59 +0100 Subject: [PATCH] Replace usage of stdenvNoCC. - For Linux, the real fix is `hardeningDisable` of "fortify"; - For macOS, the real fix is setting the C and CXX compilers in `desktop/build.sh` as well as disabling CMake install step; - Unfortunately for iOS we still need stdenvNoCC (or find a way to use GNU's ld instead of Apple's) Signed-off-by: Pedro Pombeiro --- default.nix | 5 +++-- desktop/build.sh | 10 +++++++++- scripts/build-desktop.sh | 3 +++ scripts/lib/setup/nix/desktop/default.nix | 5 +++-- scripts/lib/setup/nix/desktop/linux/default.nix | 3 +++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/default.nix b/default.nix index e8d2b8d2328..a0ca4d97a4b 100644 --- a/default.nix +++ b/default.nix @@ -20,7 +20,8 @@ with pkgs; "ios" = true; "" = true; }.${target-os} or false; - _stdenv = stdenvNoCC; # TODO: Try to use stdenv for Darwin + # TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib) + _stdenv = if target-os == "ios" || target-os == "" then stdenvNoCC else stdenv; statusDesktop = callPackage ./scripts/lib/setup/nix/desktop { inherit target-os; stdenv = _stdenv; }; statusMobile = callPackage ./scripts/lib/setup/nix/mobile { inherit target-os; stdenv = _stdenv; }; nodeInputs = import ./scripts/lib/setup/nix/global-node-packages/output { @@ -53,7 +54,6 @@ with pkgs; wget ] ++ nodePkgs ++ lib.optional isDarwin cocoapods - ++ lib.optional isLinux gcc7 ++ lib.optional targetDesktop statusDesktop.buildInputs ++ lib.optional targetMobile statusMobile.buildInputs; shellHook = @@ -68,4 +68,5 @@ with pkgs; fi set +e ''; + hardeningDisable = statusDesktop.hardeningDisable; } diff --git a/desktop/build.sh b/desktop/build.sh index 8dcec9e791f..b22eb8a4a36 100755 --- a/desktop/build.sh +++ b/desktop/build.sh @@ -34,4 +34,12 @@ echo "build.sh desktop fonts: "$desktopFonts rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile # Build project -cmake -DCMAKE_BUILD_TYPE=Debug -DEXTERNAL_MODULES_DIR="$ExternalModulesPaths" -DJS_BUNDLE_PATH="$JsBundlePath" -DDESKTOP_FONTS="$desktopFonts" . && make +cmake -DCMAKE_BUILD_TYPE=Debug \ + -DEXTERNAL_MODULES_DIR="$ExternalModulesPaths" \ + -DJS_BUNDLE_PATH="$JsBundlePath" \ + -DDESKTOP_FONTS="$desktopFonts" \ + -DCMAKE_C_COMPILER='gcc'\ + -DCMAKE_CXX_COMPILER='g++' \ + -DCMAKE_INSTALL_COMPONENT='' \ + . && \ +make diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh index ddf3b9517ef..20e8b76b44a 100755 --- a/scripts/build-desktop.sh +++ b/scripts/build-desktop.sh @@ -79,6 +79,9 @@ if is_windows_target; then CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS -DCMAKE_C_COMPILER='x86_64-w64-mingw32.shared-gcc'" CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS -DCMAKE_CXX_COMPILER='x86_64-w64-mingw32.shared-g++'" CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS -DCMAKE_RC_COMPILER='x86_64-w64-mingw32.shared-windres'" +elif is_macos; then + CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS -DCMAKE_C_COMPILER='gcc'" + CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS -DCMAKE_CXX_COMPILER='g++'" fi STATUSREACTPATH="$(cd "$SCRIPTPATH" && cd '..' && pwd)" diff --git a/scripts/lib/setup/nix/desktop/default.nix b/scripts/lib/setup/nix/desktop/default.nix index a841cc7f2d1..590f1058ef4 100644 --- a/scripts/lib/setup/nix/desktop/default.nix +++ b/scripts/lib/setup/nix/desktop/default.nix @@ -36,7 +36,8 @@ in '' else '' export QT_PATH="${qt5.full}" export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH" - '') + (lib.optionalString isDarwin '' - export MACOSX_DEPLOYMENT_TARGET=10.9 ''); + + # Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 ) + hardeningDisable = linuxPlatform.hardeningDisable; } diff --git a/scripts/lib/setup/nix/desktop/linux/default.nix b/scripts/lib/setup/nix/desktop/linux/default.nix index 4bd4844a589..048657444b9 100644 --- a/scripts/lib/setup/nix/desktop/linux/default.nix +++ b/scripts/lib/setup/nix/desktop/linux/default.nix @@ -11,4 +11,7 @@ let in { buildInputs = [ appimagekit linuxdeployqt patchelf baseImage ]; + + # Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 ) + hardeningDisable = [ "fortify" ]; }