forked from girlbossceo/conduwuit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
284 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,99 @@ | ||
{ lib | ||
, pkgsBuildHost | ||
, rust | ||
, stdenv | ||
{ | ||
lib, | ||
pkgsBuildHost, | ||
rust, | ||
stdenv, | ||
}: | ||
|
||
lib.optionalAttrs stdenv.hostPlatform.isStatic { | ||
ROCKSDB_STATIC = ""; | ||
} | ||
// | ||
{ | ||
// { | ||
CARGO_BUILD_RUSTFLAGS = | ||
lib.concatStringsSep | ||
" " | ||
([] | ||
++ lib.optionals | ||
stdenv.targetPlatform.isx86_64 | ||
[ "-C" "target-cpu=x86-64-v2" ] | ||
++ lib.optionals | ||
stdenv.targetPlatform.isAarch64 | ||
[ "-C" "target-cpu=cortex-a55" ] # cortex-a55 == ARMv8.2-a | ||
# This disables PIE for static builds, which isn't great in terms | ||
# of security. Unfortunately, my hand is forced because nixpkgs' | ||
# `libstdc++.a` is built without `-fPIE`, which precludes us from | ||
# leaving PIE enabled. | ||
++ lib.optionals | ||
stdenv.hostPlatform.isStatic | ||
[ "-C" "relocation-model=static" ] | ||
++ lib.optionals | ||
(stdenv.buildPlatform.config != stdenv.hostPlatform.config) | ||
[ "-l" "c" ] | ||
++ lib.optionals | ||
# This check has to match the one [here][0]. We only need to set | ||
# these flags when using a different linker. Don't ask me why, | ||
# though, because I don't know. All I know is it breaks otherwise. | ||
# | ||
# [0]: https://github.com/NixOS/nixpkgs/blob/5cdb38bb16c6d0a38779db14fcc766bc1b2394d6/pkgs/build-support/rust/lib/default.nix#L37-L40 | ||
( | ||
# Nixpkgs doesn't check for x86_64 here but we do, because I | ||
# observed a failure building statically for x86_64 without | ||
# including it here. Linkers are weird. | ||
(stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isx86_64) | ||
&& stdenv.hostPlatform.isStatic | ||
&& !stdenv.isDarwin | ||
&& !stdenv.cc.bintools.isLLVM | ||
) | ||
[ | ||
"-l" | ||
"stdc++" | ||
"-L" | ||
"${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib" | ||
] | ||
); | ||
" " | ||
( | ||
[] | ||
++ lib.optionals | ||
stdenv.targetPlatform.isx86_64 | ||
["-C" "target-cpu=x86-64-v2"] | ||
++ lib.optionals | ||
stdenv.targetPlatform.isAarch64 | ||
["-C" "target-cpu=cortex-a73"] # cortex-a73 == ARMv8-A | ||
# This disables PIE for static builds, which isn't great in terms | ||
# of security. Unfortunately, my hand is forced because nixpkgs' | ||
# `libstdc++.a` is built without `-fPIE`, which precludes us from | ||
# leaving PIE enabled. | ||
++ lib.optionals | ||
stdenv.hostPlatform.isStatic | ||
["-C" "relocation-model=static"] | ||
++ lib.optionals | ||
(stdenv.buildPlatform.config != stdenv.hostPlatform.config) | ||
["-l" "c"] | ||
++ lib.optionals | ||
# This check has to match the one [here][0]. We only need to set | ||
# these flags when using a different linker. Don't ask me why, | ||
# though, because I don't know. All I know is it breaks otherwise. | ||
# | ||
# [0]: https://github.com/NixOS/nixpkgs/blob/5cdb38bb16c6d0a38779db14fcc766bc1b2394d6/pkgs/build-support/rust/lib/default.nix#L37-L40 | ||
( | ||
# Nixpkgs doesn't check for x86_64 here but we do, because I | ||
# observed a failure building statically for x86_64 without | ||
# including it here. Linkers are weird. | ||
(stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isx86_64) | ||
&& stdenv.hostPlatform.isStatic | ||
&& !stdenv.isDarwin | ||
&& !stdenv.cc.bintools.isLLVM | ||
) | ||
[ | ||
"-l" | ||
"stdc++" | ||
"-L" | ||
"${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib" | ||
] | ||
); | ||
} | ||
|
||
# What follows is stolen from [here][0]. Its purpose is to properly | ||
# configure compilers and linkers for various stages of the build, and | ||
# even covers the case of build scripts that need native code compiled and | ||
# run on the build platform (I think). | ||
# | ||
# [0]: https://github.com/NixOS/nixpkgs/blob/5cdb38bb16c6d0a38779db14fcc766bc1b2394d6/pkgs/build-support/rust/lib/default.nix#L57-L80 | ||
// | ||
( | ||
// ( | ||
let | ||
inherit (rust.lib) envVars; | ||
in | ||
lib.optionalAttrs | ||
lib.optionalAttrs | ||
(stdenv.targetPlatform.rust.rustcTarget | ||
!= stdenv.hostPlatform.rust.rustcTarget) | ||
( | ||
let | ||
inherit (stdenv.targetPlatform.rust) cargoEnvVarTarget; | ||
in | ||
{ | ||
in { | ||
"CC_${cargoEnvVarTarget}" = envVars.ccForTarget; | ||
"CXX_${cargoEnvVarTarget}" = envVars.cxxForTarget; | ||
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = | ||
envVars.linkerForTarget; | ||
} | ||
) | ||
// | ||
( | ||
let | ||
inherit (stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget; | ||
in | ||
{ | ||
"CC_${cargoEnvVarTarget}" = envVars.ccForHost; | ||
"CXX_${cargoEnvVarTarget}" = envVars.cxxForHost; | ||
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForHost; | ||
CARGO_BUILD_TARGET = rustcTarget; | ||
} | ||
) | ||
// | ||
( | ||
let | ||
inherit (stdenv.buildPlatform.rust) cargoEnvVarTarget; | ||
in | ||
{ | ||
"CC_${cargoEnvVarTarget}" = envVars.ccForBuild; | ||
"CXX_${cargoEnvVarTarget}" = envVars.cxxForBuild; | ||
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForBuild; | ||
HOST_CC = "${pkgsBuildHost.stdenv.cc}/bin/cc"; | ||
HOST_CXX = "${pkgsBuildHost.stdenv.cc}/bin/c++"; | ||
} | ||
) | ||
// ( | ||
let | ||
inherit (stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget; | ||
in { | ||
"CC_${cargoEnvVarTarget}" = envVars.ccForHost; | ||
"CXX_${cargoEnvVarTarget}" = envVars.cxxForHost; | ||
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForHost; | ||
CARGO_BUILD_TARGET = rustcTarget; | ||
} | ||
) | ||
// ( | ||
let | ||
inherit (stdenv.buildPlatform.rust) cargoEnvVarTarget; | ||
in { | ||
"CC_${cargoEnvVarTarget}" = envVars.ccForBuild; | ||
"CXX_${cargoEnvVarTarget}" = envVars.cxxForBuild; | ||
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForBuild; | ||
HOST_CC = "${pkgsBuildHost.stdenv.cc}/bin/cc"; | ||
HOST_CXX = "${pkgsBuildHost.stdenv.cc}/bin/c++"; | ||
} | ||
) | ||
) |
Oops, something went wrong.