1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Fix static linking of libcxx on macOS, more portable tonlibjson (#694)

* upgrade nix to 22.11

* add static libcxx

* fix darwin dylib names

* make sure static libs are inside dylib

* apply patches only for darwin

* apply patches only for darwin

* apply patches only for darwin

* test builds

* test builds 2, remove dependency corefoundation

* test builds 3, update flake.lock

* test builds 4

* test builds 5, dontAddStaticConfigureFlags only for darwin

* test builds 6, put back CoreFoundation flag

* improve testing
This commit is contained in:
neodiX42 2023-05-19 02:24:24 -05:00 committed by GitHub
parent ef64b92f08
commit 148688572f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 19 deletions

View file

@ -36,6 +36,7 @@ jobs:
- name: Simple binaries test
run: |
sudo mv /nix/store /nix/store2
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V

View file

@ -33,6 +33,7 @@ jobs:
- name: Simple binaries test
run: |
sudo mv /nix/store /nix/store2
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V

View file

@ -35,6 +35,7 @@ jobs:
- name: Simple binaries test
run: |
sudo mv /nix/store /nix/store2
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V

View file

@ -31,6 +31,7 @@ jobs:
- name: Simple binaries test
run: |
sudo mv /nix/store /nix/store2
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V

44
flake.lock generated
View file

@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
@ -17,12 +17,15 @@
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1652776076,
"narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=",
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
@ -33,11 +36,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1659445012,
"narHash": "sha256-n8/7npmp3hLbPSTRHPW8EPO8qh9vJ10RgkRM3Ve4vfc=",
"lastModified": 1682600000,
"narHash": "sha256-ha4BehR1dh8EnXSoE1m/wyyYVvHI9txjW4w5/oxsW5Y=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a9f66ae640146ac16b6e33d2359e9171b27b0993",
"rev": "50fc86b75d2744e1ab3837ef74b53f103a9b55a0",
"type": "github"
},
"original": {
@ -49,11 +52,11 @@
},
"nixpkgs-trunk": {
"locked": {
"lastModified": 1659597264,
"narHash": "sha256-aI/r4XEZwMJnuDjIMnSiDm34vVXP6TPaWgqPIF/65SI=",
"lastModified": 1683098912,
"narHash": "sha256-bFHOixPoHZ5y44FvFgpEuZV0UYTQPNDZK/XqeUi1Lbs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2b22614150a727a8aeedc10395dbd2ff6430841b",
"rev": "abc97d3572dec126eba9fec358eb2f359a944683",
"type": "github"
},
"original": {
@ -69,8 +72,23 @@
"nixpkgs-stable": "nixpkgs-stable",
"nixpkgs-trunk": "nixpkgs-trunk"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
}

View file

@ -31,12 +31,16 @@
openssl_1_1
zlib
libmicrohttpd
] else
[
] else [
(openssl_1_1.override { static = true; }).dev
(zlib.override { shared = false; }).dev
pkgsStatic.libmicrohttpd.dev
] ++ optional staticGlibc glibc.static;
]
++ optionals (!stdenv.isDarwin) [ pkgsStatic.libmicrohttpd.dev ]
++ optionals stdenv.isDarwin [ (libiconv.override { enableStatic = true; enableShared = false; }) ]
++ optionals stdenv.isDarwin (forEach [ libmicrohttpd.dev gmp.dev nettle.dev (gnutls.override { withP11-kit = false; }).dev libtasn1.dev libidn2.dev libunistring.dev gettext ] (x: x.overrideAttrs(oldAttrs: rec { configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-shared" ]; dontDisableStatic = true; })))
++ optionals staticGlibc [ glibc.static ];
dontAddStaticConfigureFlags = stdenv.isDarwin;
cmakeFlags = [ "-DTON_USE_ABSEIL=OFF" "-DNIX=ON" ] ++ optionals staticMusl [
"-DCMAKE_CROSSCOMPILING=OFF" # pkgsStatic sets cross
@ -47,6 +51,7 @@
LDFLAGS = optional staticExternalDeps (concatStringsSep " " [
(optionalString stdenv.cc.isGNU "-static-libgcc")
(optionalString stdenv.isDarwin "-framework CoreFoundation")
"-static-libstdc++"
]);
@ -57,6 +62,14 @@
moveToOutput bin "$bin"
'';
preFixup = optionalString stdenv.isDarwin ''
for fn in "$bin"/bin/* "$out"/lib/*.dylib; do
echo Fixing libc++ in "$fn"
install_name_tool -change "$(otool -L "$fn" | grep libc++.1 | cut -d' ' -f1 | xargs)" libc++.1.dylib "$fn"
install_name_tool -change "$(otool -L "$fn" | grep libc++abi.1 | cut -d' ' -f1 | xargs)" libc++abi.dylib "$fn"
done
'';
outputs = [ "bin" "out" ];
};
hostPkgs = system:
@ -131,10 +144,10 @@
};
ton-staticbin-dylib = host.symlinkJoin {
name = "ton";
paths = [ ton-static.bin ton-normal.out ];
paths = [ ton-static.bin ton-static.out ];
};
};
devShells.default =
host.mkShell { inputsFrom = [ packages.ton-normal ]; };
})));
}
}