Merge pull request #232239 from wegank/vlang-darwin
vlang: fix build on darwin, cleanup
This commit is contained in:
commit
cad5b82d2a
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx, pkgsStatic, xorg, binaryen }:
|
||||
{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, makeWrapper, upx, boehmgc, xorg, binaryen, darwin }:
|
||||
|
||||
let
|
||||
version = "weekly.2023.19";
|
||||
@ -33,6 +33,9 @@ let
|
||||
rev = "6e970bd0a7459ad7798588f1ace4aa46c5e789a2";
|
||||
hash = "sha256-hFf7c8ZNMU1j7fgmDakuO7tBVr12Wq0dgQddJnkMajE=";
|
||||
};
|
||||
boehmgcStatic = boehmgc.override {
|
||||
enableStatic = true;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "vlang";
|
||||
@ -50,41 +53,32 @@ stdenv.mkDerivation {
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
buildInputs = [
|
||||
binaryen
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
darwin.apple_sdk.frameworks.Cocoa
|
||||
] ++ lib.optionals stdenv.isLinux [
|
||||
xorg.libX11
|
||||
xorg.libXau
|
||||
xorg.libXdmcp
|
||||
xorg.xorgproto
|
||||
];
|
||||
|
||||
makeFlags = [
|
||||
"local=1"
|
||||
];
|
||||
|
||||
env.VC = vc;
|
||||
env.VFLAGS = if stdenv.isDarwin then
|
||||
# on darwin we need to add a manual link to libgc since it doesn't have a libgc.a
|
||||
"-cg -cc ${pkgsStatic.clang}/bin/clang -no-retry-compilation -ldflags -L${pkgsStatic.boehmgc}/lib -ldflags -lgc -ldflags -L${binaryen}/lib"
|
||||
else
|
||||
# libX11.dev and xorg.xorgproto are needed because of
|
||||
# builder error: Header file <X11/Xlib.h>, needed for module `clipboard.x11` was not found. Please install a package with the X11 development headers, for example: `apt-get install libx11-dev`.
|
||||
# libXau, libxcb, libXdmcp need to be static if you use static gcc otherwise
|
||||
# /nix/store/xnk2z26fqy86xahiz3q797dzqx96sidk-glibc-2.37-8/lib/libc.so.6: undefined reference to `_rtld_glob al_ro@GLIBC_PRIVATE'
|
||||
"-cc ${pkgsStatic.gcc}/bin/gcc -no-retry-compilation -cflags -I${xorg.libX11.dev}/include -cflags -I${xorg.xorgproto}/include -ldflags -L${binaryen}/lib -ldflags -L${pkgsStatic.xorg.libX11}/lib -ldflags -L${pkgsStatic.xorg.libxcb}/lib -ldflags -lxcb -ldflags -L${pkgsStatic.xorg.libXau}/lib -ldflags -lXau -ldflags -L${pkgsStatic.xorg.libXdmcp}/lib -ldflags -lXdmcp";
|
||||
|
||||
preBuild = ''
|
||||
export HOME=$(mktemp -d)
|
||||
mkdir -p ./thirdparty/tcc/lib
|
||||
# this step is not needed it's just to silence a warning
|
||||
# we don't use tcc at all since it fails on a missing libatomic
|
||||
ln -s ${pkgsStatic.tinycc}/bin/tcc ./thirdparty/tcc/tcc.exe
|
||||
cp -r ${pkgsStatic.boehmgc}/lib/* ./thirdparty/tcc/lib
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
# this file isn't used by clang, but it's just to silence a warning
|
||||
# the compiler complains on an empty file, so this makes it "close" to real
|
||||
substituteInPlace vlib/builtin/builtin_d_gcboehm.c.v \
|
||||
--replace "libgc.a" "libgc.la"
|
||||
cp -r ${boehmgcStatic}/lib/* ./thirdparty/tcc/lib
|
||||
'';
|
||||
|
||||
# vcreate_test.v requires git, so we must remove it when building the tools.
|
||||
# vtest.v fails on Darwin, so let's just disable it for now.
|
||||
preInstall = ''
|
||||
mv cmd/tools/vcreate/vcreate_test.v $HOME/vcreate_test.v
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
mv cmd/tools/vtest.v $HOME/vtest.v
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
@ -110,8 +104,6 @@ stdenv.mkDerivation {
|
||||
# Return vcreate_test.v and vtest.v, so the user can use it.
|
||||
postInstall = ''
|
||||
cp $HOME/vcreate_test.v $out/lib/cmd/tools/vcreate_test.v
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
cp $HOME/vtest.v $out/lib/cmd/tools/vtest.v
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
|
@ -4,6 +4,7 @@
|
||||
# doc: https://github.com/ivmai/bdwgc/blob/v8.2.2/doc/README.macros (LARGE_CONFIG)
|
||||
, enableLargeConfig ? false
|
||||
, enableMmap ? true
|
||||
, enableStatic ? false
|
||||
, nixVersions
|
||||
}:
|
||||
|
||||
@ -26,6 +27,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"--enable-cplusplus"
|
||||
"--with-libatomic-ops=none"
|
||||
]
|
||||
++ lib.optional enableStatic "--enable-static"
|
||||
++ lib.optional enableMmap "--enable-mmap"
|
||||
++ lib.optional enableLargeConfig "--enable-large-config";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user