authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-07 19:09:43-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-12-07 19:09:43-05:00
log913b4a3f19955296a892ffe4f148f8c097a7732a
tree564c5ac6d5f2014c3f7df862f30eb78ec20b2c42
parent096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2
parent1122d9d212f2147e12675eb86565d63d2b0949a5
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #13802 from ziglang/windows-lib-name

CI: make Windows build from source like every other system

3 files changed, 65 insertions(+), 39 deletions(-)

build.zig+24-7
...@@ -280,6 +280,13 @@ pub fn build(b: *Builder) !void {...@@ -280,6 +280,13 @@ pub fn build(b: *Builder) !void {
280 try addStaticLlvmOptionsToExe(exe);280 try addStaticLlvmOptionsToExe(exe);
281 try addStaticLlvmOptionsToExe(test_cases);281 try addStaticLlvmOptionsToExe(test_cases);
282 }282 }
283 if (target.isWindows()) {
284 inline for (.{ exe, test_cases }) |artifact| {
285 artifact.linkSystemLibrary("version");
286 artifact.linkSystemLibrary("uuid");
287 artifact.linkSystemLibrary("ole32");
288 }
289 }
283 }290 }
284291
285 const semver = try std.SemanticVersion.parse(version);292 const semver = try std.SemanticVersion.parse(version);
...@@ -537,7 +544,11 @@ fn addCmakeCfgOptionsToExe(...@@ -537,7 +544,11 @@ fn addCmakeCfgOptionsToExe(
537 exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{544 exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
538 cfg.cmake_binary_dir,545 cfg.cmake_binary_dir,
539 "zigcpp",546 "zigcpp",
540 b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }),547 b.fmt("{s}{s}{s}", .{
548 cfg.cmake_static_library_prefix,
549 "zigcpp",
550 cfg.cmake_static_library_suffix,
551 }),
541 }) catch unreachable);552 }) catch unreachable);
542 assert(cfg.lld_include_dir.len != 0);553 assert(cfg.lld_include_dir.len != 0);
543 exe.addIncludePath(cfg.lld_include_dir);554 exe.addIncludePath(cfg.lld_include_dir);
...@@ -610,12 +621,6 @@ fn addStaticLlvmOptionsToExe(exe: *std.build.LibExeObjStep) !void {...@@ -610,12 +621,6 @@ fn addStaticLlvmOptionsToExe(exe: *std.build.LibExeObjStep) !void {
610621
611 // This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries.622 // This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries.
612 exe.linkSystemLibrary("c++");623 exe.linkSystemLibrary("c++");
613
614 if (exe.target.getOs().tag == .windows) {
615 exe.linkSystemLibrary("version");
616 exe.linkSystemLibrary("uuid");
617 exe.linkSystemLibrary("ole32");
618 }
619}624}
620625
621fn addCxxKnownPath(626fn addCxxKnownPath(
...@@ -669,6 +674,8 @@ const CMakeConfig = struct {...@@ -669,6 +674,8 @@ const CMakeConfig = struct {
669 llvm_linkage: std.build.LibExeObjStep.Linkage,674 llvm_linkage: std.build.LibExeObjStep.Linkage,
670 cmake_binary_dir: []const u8,675 cmake_binary_dir: []const u8,
671 cmake_prefix_path: []const u8,676 cmake_prefix_path: []const u8,
677 cmake_static_library_prefix: []const u8,
678 cmake_static_library_suffix: []const u8,
672 cxx_compiler: []const u8,679 cxx_compiler: []const u8,
673 lld_include_dir: []const u8,680 lld_include_dir: []const u8,
674 lld_libraries: []const u8,681 lld_libraries: []const u8,
...@@ -732,6 +739,8 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {...@@ -732,6 +739,8 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
732 .llvm_linkage = undefined,739 .llvm_linkage = undefined,
733 .cmake_binary_dir = undefined,740 .cmake_binary_dir = undefined,
734 .cmake_prefix_path = undefined,741 .cmake_prefix_path = undefined,
742 .cmake_static_library_prefix = undefined,
743 .cmake_static_library_suffix = undefined,
735 .cxx_compiler = undefined,744 .cxx_compiler = undefined,
736 .lld_include_dir = undefined,745 .lld_include_dir = undefined,
737 .lld_libraries = undefined,746 .lld_libraries = undefined,
...@@ -751,6 +760,14 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {...@@ -751,6 +760,14 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
751 .prefix = "#define ZIG_CMAKE_PREFIX_PATH ",760 .prefix = "#define ZIG_CMAKE_PREFIX_PATH ",
752 .field = "cmake_prefix_path",761 .field = "cmake_prefix_path",
753 },762 },
763 .{
764 .prefix = "#define ZIG_CMAKE_STATIC_LIBRARY_PREFIX ",
765 .field = "cmake_static_library_prefix",
766 },
767 .{
768 .prefix = "#define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX ",
769 .field = "cmake_static_library_suffix",
770 },
754 .{771 .{
755 .prefix = "#define ZIG_CXX_COMPILER ",772 .prefix = "#define ZIG_CXX_COMPILER ",
756 .field = "cxx_compiler",773 .field = "cxx_compiler",
ci/x86_64-windows.ps1+35-28
...@@ -1,20 +1,18 @@...@@ -1,20 +1,18 @@
1$TARGET = "$($Env:ARCH)-windows-gnu"1$TARGET = "$($Env:ARCH)-windows-gnu"
2$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.448+e6e459e9e"2$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.448+e6e459e9e"
3$MCPU = "baseline"
3$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"4$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
5$PREFIX_PATH = "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME"
6$ZIG = "$PREFIX_PATH\bin\zig.exe"
7$ZIG_LIB_DIR = "$(Get-Location)\lib"
48
5Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"9Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
6
7Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip"10Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip"
811
9Write-Output "Extracting..."12Write-Output "Extracting..."
10
11Add-Type -AssemblyName System.IO.Compression.FileSystem ;13Add-Type -AssemblyName System.IO.Compression.FileSystem ;
12[System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD")14[System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD")
1315
14Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib"
15Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release"
16Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME"
17
18function CheckLastExitCode {16function CheckLastExitCode {
19 if (!$?) {17 if (!$?) {
20 exit 118 exit 1
...@@ -31,32 +29,41 @@ if ((git rev-parse --is-shallow-repository) -eq "true") {...@@ -31,32 +29,41 @@ if ((git rev-parse --is-shallow-repository) -eq "true") {
31 git fetch --unshallow # `git describe` won't work on a shallow repo29 git fetch --unshallow # `git describe` won't work on a shallow repo
32}30}
3331
34Write-Output "Building Zig..."32Write-Output "Building from source..."
33Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore
34New-Item -Path 'build-release' -ItemType Directory
35Set-Location -Path 'build-release'
3536
36& "$ZIGPREFIXPATH\bin\zig.exe" build `37# CMake gives a syntax error when file paths with backward slashes are used.
37 --prefix "$ZIGINSTALLDIR" `38# Here, we use forward slashes only to work around this.
38 --search-prefix "$ZIGPREFIXPATH" `39& cmake .. `
39 --zig-lib-dir "$ZIGLIBDIR" `40 -GNinja `
40 -Dstatic-llvm `41 -DCMAKE_INSTALL_PREFIX="stage3-release" `
41 -Drelease `42 -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
42 -Duse-zig-libcxx `43 -DCMAKE_BUILD_TYPE=Release `
43 -Dtarget="$TARGET"44 -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
45 -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
46 -DZIG_TARGET_TRIPLE="$TARGET" `
47 -DZIG_TARGET_MCPU="$MCPU" `
48 -DZIG_STATIC=ON
44CheckLastExitCode49CheckLastExitCode
4550
46Write-Output " zig build test docs..."51ninja install
47
48& "$ZIGINSTALLDIR\bin\zig.exe" build test docs `
49 --search-prefix "$ZIGPREFIXPATH" `
50 -Dstatic-llvm `
51 -Dskip-non-native `
52 -Denable-symlinks-windows
53CheckLastExitCode52CheckLastExitCode
5453
55# Produce the experimental std lib documentation.54Write-Output "Main test suite..."
56Write-Output "zig test std/std.zig..."55& "stage3-release\bin\zig.exe" build test docs `
56 --zig-lib-dir "$ZIG_LIB_DIR" `
57 --search-prefix "$PREFIX_PATH" `
58 -Dstatic-llvm `
59 -Dskip-non-native `
60 -Denable-symlinks-windows
61CheckLastExitCode
5762
58& "$ZIGINSTALLDIR\bin\zig.exe" test "$ZIGLIBDIR\std\std.zig" `63Write-Output "Testing Autodocs..."
59 --zig-lib-dir "$ZIGLIBDIR" `64& "stage3-release\bin\zig.exe" test "..\lib\std\std.zig" `
60 -femit-docs `65 --zig-lib-dir "$ZIG_LIB_DIR" `
61 -fno-emit-bin66 -femit-docs `
67 -fno-emit-bin
62CheckLastExitCode68CheckLastExitCode
69
stage1/config.h.in+6-4
...@@ -15,16 +15,18 @@...@@ -15,16 +15,18 @@
15#define ZIG_VERSION_STRING "@ZIG_VERSION@"15#define ZIG_VERSION_STRING "@ZIG_VERSION@"
1616
17// Used by build.zig for communicating build information to self hosted build.17// Used by build.zig for communicating build information to self hosted build.
18#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
18#define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"19#define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"
19#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@"
20#define ZIG_CMAKE_PREFIX_PATH "@ZIG_CMAKE_PREFIX_PATH@"20#define ZIG_CMAKE_PREFIX_PATH "@ZIG_CMAKE_PREFIX_PATH@"
21#define ZIG_CMAKE_STATIC_LIBRARY_PREFIX "@CMAKE_STATIC_LIBRARY_PREFIX@"
22#define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX "@CMAKE_STATIC_LIBRARY_SUFFIX@"
21#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"23#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
24#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
22#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"25#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
23#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"26#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
24#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
25#define ZIG_LLVM_INCLUDE_PATH "@LLVM_INCLUDE_DIRS@"27#define ZIG_LLVM_INCLUDE_PATH "@LLVM_INCLUDE_DIRS@"
26#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
27#define ZIG_LLVM_LIBRARIES "@LLVM_LIBRARIES@"28#define ZIG_LLVM_LIBRARIES "@LLVM_LIBRARIES@"
28#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"29#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
30#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@"
2931
30#endif32#endif