Commit Graph

702 Commits

Author SHA1 Message Date
Jakub Konka
069fe0d63f update CMakeLists.txt with new entries 2023-01-19 00:35:33 +01:00
kcbanner
3cacbea95b build: simplify llvm-config provided system library parsing
- Revert the addition of CLANG_SYSTEM_LIBARIES and LLVM_SYSTEM_LIBRARIES
- Change addCMakeLibraryList to parse non-absolute path .lib dependencies as system libraries
2023-01-04 21:45:06 -05:00
kcbanner
f5135f8e3b cmake: fix handling of transitive zstd dependency
- Remove ZIG_ENABLE_ZSTD in favour of allowing ZIG_STATIC_ZSTD to be toggled off explicitly when ZIG_STATIC is on
- Remove ZIG_ENABLE_LIBCPP (now unused)
2023-01-04 21:45:06 -05:00
kcbanner
88e442253b cmake: add /FORCE:MULTIPLE to handle fabsl being defined in compiler_rt as well as libcmpt 2023-01-04 21:45:06 -05:00
kcbanner
bd252c58bc cmake: /O0 -> /Od 2023-01-04 21:45:06 -05:00
kcbanner
701996083a cmake: /std:c99 isn't a valid cl option 2023-01-04 21:45:06 -05:00
kcbanner
b42442f5b4 windows: fixes to support using zig cc/c++ with CMake on Windows
Using zig cc with CMake on Windows was failing during compiler
detection. -nostdinc was causing the crt not to be linked, and Coff/lld.zig
assumed that wWinMainCRTStartup would be present in this case.

-nostdlib did not prevent the default behaviour of linking libc++ when
zig c++ was used. This caused libc++ to be built when CMake ran
ABI detection using zig c++, which fails as libcxxabi cannot compile
under MSVC.

- Change the behaviour of COFF -nostdinc to set /entry to the function that the
default CRT method for the specified subsystem would have called.
- Fix -ENTRY being passed twice if it was specified explicitly and -nostdlib was present.
- Add support for /pdb, /version, /implib, and /subsystem as linker args (passed by CMake)
- Remove -Ddisable-zstd, no longer needed
- Add -Ddisable-libcpp for use when bootstrapping on msvc
2023-01-04 21:45:06 -05:00
kcbanner
0471eea0e2 build: first pass on geting stage3 building under x64_64-windows-msvc 2023-01-04 21:45:05 -05:00
kcbanner
c3945d9ede cmake: output binaries to the build directory (ie. instead of Release/Debug subfolders) 2023-01-04 21:45:05 -05:00
Michael Dusan
0cb8ed6b85
cmake: ignore case for TARGET ARCH/OS mapping
- first convert to lower-case then perform mappings
- effect: freebsd, netbsd and openbsd convert arch `amd64` to `x86_64`
- effect: convert `arm64` to `aarch64`
2023-01-02 19:18:32 -05:00
Kim SHrier
5bde627f9d map lower case amd64 to x86_64 2022-12-24 02:23:31 -05:00
Frank Denis
8d66aacb64
compiler-rt: implement __udivei4 and __umodei4 (#14023)
Allows dividing and formatting arbitrary-large unsigned integers.
2022-12-22 16:29:19 -05:00
Jakub Konka
585c21e54d macho: move parallel file hashing back to CodeSignature
I need to think some more how to calculate UUID in parallel, if
it is even possible, to preserve UUID's determinism.
2022-12-16 18:05:58 +01:00
Jakub Konka
660270b7a9 macho: calculate UUID excluding stabs and part of contributing strtab 2022-12-16 18:05:58 +01:00
Jakub Konka
79457fc76a macho: generalize parallel hasher; impl parallel MD5-like hash
By pulling out the parallel hashing setup from `CodeSignature.zig`,
we can now reuse it different places across MachO linker (for now;
I can totally see its usefulness beyond MachO, eg. in COFF or ELF too).
The parallel hasher is generic over actual hasher such as Sha256 or MD5.
The implementation is kept as it was.

For UUID calculation, depending on the linking mode:
* incremental - since it only supports debug mode, we don't bother with MD5
  hashing of the contents, and populate it with random data but only once
  per a sequence of in-place binary patches
* traditional - in debug, we use random string (for speed); in release,
  we calculate the hash, however we use LLVM/LLD's trick in that we
  calculate a series of MD5 hashes in parallel and then one an MD5 of MD5
  final hash to generate digest.
2022-12-16 00:01:04 +01:00
Jakub Konka
ec40c6b28f macho: calculate UUID as a streaming MD5 hash of the file contents 2022-12-16 00:01:04 +01:00
Jakub Konka
db2052bc35 macho: dedup LC emitting logic
Fix path written to `LC_ID_DYLIB` to include the current CWD (if any).
2022-12-16 00:01:04 +01:00
Andrew Kelley
c079d5b15d CMake: fix aarch64-windows target detection 2022-12-10 16:28:49 -07:00
Andrew Kelley
cacb962ba7 CMake: add workaround for CMAKE_AR not supporting spaces
This allows using `zig ar` for `CMAKE_AR`. Unfortunately, it requires a
patch to CMakeLists.txt and cannot be done merely with flags to the
cmake line.
2022-12-10 16:28:49 -07:00
Andrew Kelley
c51288f1f6 remove the zstd mechanism from the build process 2022-12-09 20:59:13 -07:00
h57624paen
b483c796c6 fix building wasm2c output with msvc
cmake tweaks to allow zig1 to compile successfully with msvc
2022-12-09 22:35:05 -05:00
Jacob Young
a0a2e75773 cmake: disable stack protector for zig2 to avoid link errors on windows
On windows we get:

    lld-link: error: undefined symbol: __stack_chk_fail
    >>> referenced by CMakeFiles/zig2.dir/zig2.c.obj:(main)
    >>> referenced by CMakeFiles/zig2.dir/zig2.c.obj:(main_main)
    >>> referenced by CMakeFiles/zig2.dir/zig2.c.obj:(log_scoped_28_default_29_err__anon_2764)
    >>> referenced 36192 more times

    lld-link: error: undefined symbol: __stack_chk_guard
    >>> referenced by CMakeFiles/zig2.dir/zig2.c.obj:(.refptr.__stack_chk_guard)
    >>> referenced by CMakeFiles/zig2.dir/compiler_rt.c.obj
2022-12-06 12:27:28 -07:00
Jacob Young
98338358ed cmake: fix bootstrap dependencies 2022-12-06 12:27:28 -07:00
Andrew Kelley
eef4348953 CMake: remove --color on for compiler_rt too
Missing change from bcd4ea9b28a7560a1c1ef28c6c7258c6126c80e5
2022-12-06 12:27:28 -07:00
Andrew Kelley
aaf95ce849 CMake: adjust apple clang compiler check
Before it was checking if the compiler was AppleClang, however, this did
not handle the case when using a compiled-from-source Clang on a macOS
computer, in which case the linker is still Apple ld64, and it is in
fact the linker that needs to have the different flag to communicate
stack size.
2022-12-06 12:15:05 -07:00
Andrew Kelley
ec1334d2d4 CMake: remove --color on
This flag makes CI servers print garbage to the terminal. I started
implementing detection in wasi.c, but it would have destroyed the
beautiful code that only touches the C stdlib, does not do any
conditional compilation based on the operating system, or rely on any
POSIX functions.

So instead, let's just do without this flag to retain simplicity in this
step of the build process.
2022-12-06 12:15:05 -07:00
Jacob Young
9f4ef4de23 wasm2c: remove unnecessary brackets to reduce max bracket depth
This avoids the need to pass `-fbracket-depth=512` to clang.
2022-12-06 12:15:04 -07:00
Jacob Young
fdb98c5ce1 cmake: fix stack size linker argument on mac 2022-12-06 12:15:04 -07:00
Jacob Young
687ea31ef9 cmake: fix host target detection 2022-12-06 12:15:04 -07:00
Andrew Kelley
54b960aa4d CMake: add the bracket-depth workaround for zig1 2022-12-06 12:15:04 -07:00
Andrew Kelley
1e638cb206 CMake adjustments 2022-12-06 12:15:04 -07:00
Jacob Young
1263346774 use zig-wasm2c for bootstrapping 2022-12-06 12:15:04 -07:00
Andrew Kelley
a63305bc50 CMake: use ReleaseSmall instead of ReleaseFast
When producing C source code. This enables strip, which should avoid
bloat and save compilation time.
2022-12-06 12:15:04 -07:00
Andrew Kelley
fd54a01499 CMake: rebuild when the wasm blob changes 2022-12-06 12:15:04 -07:00
Andrew Kelley
02456a32ad CI: make Windows build from source like everybody else
Now that OOM is no longer a problem, the Windows CI can do the same
process every other system does instead of building from a recent Zig
binary.
2022-12-06 12:15:04 -07:00
Andrew Kelley
ba8d5fc7f8 CMake: no optimization for zig1.c and zig2.c 2022-12-06 12:15:04 -07:00
Matt Knight
e9d9be2902 Some fixes for the wasi interpreter for macOS (#13587)
* Remove usage of O_PATH, ifdef for macos stat struct, and integer formatting
2022-12-06 12:15:04 -07:00
Andrew Kelley
eef780ebf2 CMake: use -O1 instead of -O2 for building generated .c code
Idea here is that this is a sweet spot of not wasting time waiting for
optimizations but also getting decent runime performance.
2022-12-06 12:15:04 -07:00
Andrew Kelley
33e3db11fe zig1.c: autodetect host target triple
instead of assuming x8_64-linux in CMake
2022-12-06 12:15:04 -07:00
Andrew Kelley
34e9bbb9d4 enable the LLVM backend in stage2
This takes a bit longer since the interpreted part has to do more work
but it saves a round trip through the compiler by allowing `zig2 build`
to be the final step. 1-2-3, done.

For me this is currently failing due to compilation errors generated by
GCC when compiling zig2.c but in theory if those are fixed, it should
work!
2022-12-06 12:15:04 -07:00
Andrew Kelley
fb9a6084e2 zig1.c: decompress zig1.wasm.zst with zstd 2022-12-06 12:15:04 -07:00
Andrew Kelley
39fd77bc16 interpret the WASI blob to produce zig2.c and compiler_rt.c
* synchronize zig1.c from zig-wasi external project
 * change the way argv works to avoid absolute paths
 * autodetect isatty
 * compiler_rt: disable some functions when object format is C
 * add missing flag from config.zig.in

The next problem is that compiling compiler_rt.c with gcc gives
"conflicting types" errors for `__eqhf2` and friends.
2022-12-06 12:15:04 -07:00
Andrew Kelley
ef447c3eca redo CMakeLists.txt to use WASI interpreter
current status is that it hits error: OutOfMemory for unknown reasons,
probably due to bugs in the C WASI interpreter port.
2022-12-06 12:15:04 -07:00
Andrew Kelley
28514476ef remove -fstage1 option
After this commit, the self-hosted compiler does not offer the option to
use stage1 as a backend anymore.
2022-12-06 12:15:04 -07:00
Andrew Kelley
e18d310afd CI: build from old zig on x86_64-linux debug
This is to work around OOM on the CI server. Once #13560 is complete,
we can avoid having to replace the tarballs so often.
2022-11-22 00:56:44 -07:00
Andrew Kelley
5ec9be0b03 CMake: choose native CPU instead of baseline by default 2022-11-21 20:16:08 -07:00
Cody Tapscott
b605cb2742 cmake: Mark <root>/.git/HEAD as a configure dependency
This ensures that the Zig version will be re-computed when jumping
through the source tree, which is especially important if bisecting
across AstGen- or other changes that must not use the old cache.
2022-11-10 19:34:56 -05:00
Andrew Kelley
841235b3fd start the 0.11.0 release cycle 2022-10-31 10:25:46 -07:00
Andrew Kelley
0b99e5e4c4 build: rename the "skip lib files" option
* Old cmake option: `-DZIG_SKIP_INSTALL_LIB_FILES=ON`
 * New cmake option: `-DZIG_NO_LIB=ON`
 * Old build.zig option: `-Dskip-install-lib-files`
 * New build.zig option: `-Dno-lib`

Motivation is making build commands easier to type.
2022-10-27 15:18:00 -07:00
Andrew Kelley
8fc7b4d140 CMake: handle zstd the same as zlib
This is a new dependency of LLVM 15.
2022-10-25 18:29:39 -07:00