-
Notifications
You must be signed in to change notification settings - Fork 420
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
43 additions
and
19 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
set -uo pipefail | ||
|
||
# use with clang64 MinGW shell! | ||
# run from root build directory (from inside nix-shell or otherwise defining GLIBC/GCC_DEV/GCC_LIBS/GMP) as in | ||
# ``` | ||
# eval cmake ../.. $(../../script/prepare-llvm-mingw.sh) | ||
# ``` | ||
|
||
# use full mingw clang for compiling C++ code, but subset for compiling C code and distribution | ||
|
||
root="$(realpath .)/stage1" | ||
mkdir -p stage1/{bin,lib,lib/windows,include/clang} | ||
# a C compiler! | ||
cp $(which clang) stage1/bin/ | ||
# a linker! | ||
cp $(which ld.lld) stage1/bin/ | ||
# many dependencies! | ||
cp $(ldd stage1/bin/* | cut -f3 -d' ' | grep clang64) stage1/bin | ||
# lean.h dependencies | ||
cp /clang64/lib/clang/*/include/{std*,__std*,limits}.h stage1/include/clang | ||
# single Windows dependency | ||
echo ' | ||
// https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode | ||
#define SEM_FAILCRITICALERRORS 0x0001 | ||
__declspec(dllimport) __stdcall unsigned int SetErrorMode(unsigned int uMode);' > stage1/include/clang/windows.h | ||
# COFF dependencies | ||
cp /clang64/x86_64-w64-mingw32/lib/{crtbegin,crtend,crt2,dllcrt2}.o stage1/lib/ | ||
# further dependencies | ||
cp /clang64/x86_64-w64-mingw32/lib/lib{m,bcrypt,mingw32,moldname,mingwex,msvcrt,pthread,advapi32,shell32,user32,kernel32}.* /clang64/lib/lib{c++,gmp,unwind}.* stage1/lib/ | ||
(cd /clang64; cp --parents lib/clang/*/lib/windows/libclang_rt.builtins-x86_64.a "$root") | ||
cp /clang64/bin/libgmp-* stage1/bin/ | ||
echo -n " -DLEAN_USE_LIBCXX=ON" | ||
echo -n " -DLEANC_INTERNAL_FLAGS='--sysroot ROOT -I ROOT/include/clang' -DLEANC_CC=ROOT/bin/clang.exe -DCMAKE_C_COMPILER=$PWD/stage1/bin/clang.exe" | ||
echo -n " -DLEANC_INTERNAL_LINKER_FLAGS='-L ROOT/lib -fuse-ld=ROOT/bin/ld.lld.exe'" | ||
echo -n " -DAUTO_THREAD_FINALIZATION=OFF -DSTAGE0_AUTO_THREAD_FINALIZATION=OFF" | ||
#echo -n " -DLEAN_TEST_VARS='LD_LIBRARY_PATH=$PWD/stage1/lib:\${LD_LIBRARY_PATH:-}'" |