Skip to content

Commit d888bd2

Browse files
authored
Merge branch 'master' into hmcty/f80
2 parents c103c12 + c40708a commit d888bd2

File tree

120 files changed

+8420
-8014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+8420
-8014
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Build and Test
4444
run: sh ci/aarch64-linux-release.sh
4545
x86_64-macos-release:
46-
runs-on: "macos-11"
46+
runs-on: "macos-12"
4747
env:
4848
ARCH: "x86_64"
4949
steps:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ set(ZIG_STAGE2_SOURCES
522522
src/Sema.zig
523523
src/Sema/bitcast.zig
524524
src/Sema/comptime_ptr_access.zig
525+
src/Type.zig
525526
src/Value.zig
526527
src/Zcu.zig
527528
src/arch/aarch64/CodeGen.zig
@@ -673,7 +674,6 @@ set(ZIG_STAGE2_SOURCES
673674
src/target.zig
674675
src/tracy.zig
675676
src/translate_c.zig
676-
src/type.zig
677677
src/wasi_libc.zig
678678
)
679679

build.zig

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ pub fn build(b: *std.Build) !void {
8282
docs_step.dependOn(langref_step);
8383
docs_step.dependOn(std_docs_step);
8484

85-
const check_case_exe = b.addExecutable(.{
86-
.name = "check-case",
87-
.root_source_file = b.path("test/src/Cases.zig"),
88-
.target = b.graph.host,
89-
.optimize = optimize,
90-
.single_threaded = single_threaded,
91-
});
92-
check_case_exe.stack_size = stack_size;
93-
9485
const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;
9586
const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
9687
const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;
@@ -222,7 +213,6 @@ pub fn build(b: *std.Build) !void {
222213
if (target.result.os.tag == .windows and target.result.abi == .gnu) {
223214
// LTO is currently broken on mingw, this can be removed when it's fixed.
224215
exe.want_lto = false;
225-
check_case_exe.want_lto = false;
226216
}
227217

228218
const use_llvm = b.option(bool, "use-llvm", "Use the llvm backend");
@@ -245,7 +235,6 @@ pub fn build(b: *std.Build) !void {
245235

246236
if (link_libc) {
247237
exe.linkLibC();
248-
check_case_exe.linkLibC();
249238
}
250239

251240
const is_debug = optimize == .Debug;
@@ -339,21 +328,17 @@ pub fn build(b: *std.Build) !void {
339328
}
340329

341330
try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx);
342-
try addCmakeCfgOptionsToExe(b, cfg, check_case_exe, use_zig_libcxx);
343331
} else {
344332
// Here we are -Denable-llvm but no cmake integration.
345333
try addStaticLlvmOptionsToExe(exe);
346-
try addStaticLlvmOptionsToExe(check_case_exe);
347334
}
348335
if (target.result.os.tag == .windows) {
349-
inline for (.{ exe, check_case_exe }) |artifact| {
350-
// LLVM depends on networking as of version 18.
351-
artifact.linkSystemLibrary("ws2_32");
336+
// LLVM depends on networking as of version 18.
337+
exe.linkSystemLibrary("ws2_32");
352338

353-
artifact.linkSystemLibrary("version");
354-
artifact.linkSystemLibrary("uuid");
355-
artifact.linkSystemLibrary("ole32");
356-
}
339+
exe.linkSystemLibrary("version");
340+
exe.linkSystemLibrary("uuid");
341+
exe.linkSystemLibrary("ole32");
357342
}
358343
}
359344

@@ -394,7 +379,6 @@ pub fn build(b: *std.Build) !void {
394379
const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
395380

396381
const test_cases_options = b.addOptions();
397-
check_case_exe.root_module.addOptions("build_options", test_cases_options);
398382

399383
test_cases_options.addOption(bool, "enable_tracy", false);
400384
test_cases_options.addOption(bool, "enable_debug_extensions", enable_debug_extensions);
@@ -458,7 +442,7 @@ pub fn build(b: *std.Build) !void {
458442
test_step.dependOn(check_fmt);
459443

460444
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
461-
try tests.addCases(b, test_cases_step, test_filters, check_case_exe, target, .{
445+
try tests.addCases(b, test_cases_step, test_filters, target, .{
462446
.skip_translate_c = skip_translate_c,
463447
.skip_run_translated_c = skip_run_translated_c,
464448
}, .{

cmake/Findllvm.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ if(ZIG_USE_LLVM_CONFIG)
176176
OUTPUT_STRIP_TRAILING_WHITESPACE)
177177
string(REPLACE " " ";" LLVM_INCLUDE_DIRS "${LLVM_INCLUDE_DIRS_SPACES}")
178178

179-
link_directories("${CMAKE_PREFIX_PATH}/lib")
180179
link_directories("${LLVM_LIBDIRS}")
181180
else()
182181
# Here we assume that we're cross compiling with Zig, of course. No reason

lib/compiler/aro/aro/Driver.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ fn processSource(
730730
defer obj.deinit();
731731

732732
// If it's used, name_buf will either hold a filename or `/tmp/<12 random bytes with base-64 encoding>.<extension>`
733-
// both of which should fit into MAX_NAME_BYTES for all systems
734-
var name_buf: [std.fs.MAX_NAME_BYTES]u8 = undefined;
733+
// both of which should fit into max_name_bytes for all systems
734+
var name_buf: [std.fs.max_name_bytes]u8 = undefined;
735735

736736
const out_file_name = if (d.only_compile) blk: {
737737
const fmt_template = "{s}{s}";

lib/compiler/aro/aro/Parser.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8011,7 +8011,7 @@ fn charLiteral(p: *Parser) Error!Result {
80118011
const slice = char_kind.contentSlice(p.tokSlice(p.tok_i));
80128012

80138013
var is_multichar = false;
8014-
if (slice.len == 1 and std.ascii.isASCII(slice[0])) {
8014+
if (slice.len == 1 and std.ascii.isAscii(slice[0])) {
80158015
// fast path: single unescaped ASCII char
80168016
val = slice[0];
80178017
} else {

lib/libc/include/generic-glibc/stdlib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,11 @@ extern int lcong48_r (unsigned short int __param[7],
653653
struct drand48_data *__buffer)
654654
__THROW __nonnull ((1, 2));
655655

656+
/*
657+
* arc4random* symbols introduced in glibc 2.36:
658+
* https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=8420a65cd06874ee09518366b8fba746a557212a;hb=6f4e0fcfa2d2b0915816a3a3a1d48b4763a7dee2
659+
*/
660+
# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2
656661
/* Return a random integer between zero and 2**32-1 (inclusive). */
657662
extern __uint32_t arc4random (void)
658663
__THROW __wur;
@@ -665,6 +670,7 @@ extern void arc4random_buf (void *__buf, size_t __size)
665670
limit (exclusive). */
666671
extern __uint32_t arc4random_uniform (__uint32_t __upper_bound)
667672
__THROW __wur;
673+
# endif /* glibc v2.36 and later */
668674
# endif /* Use misc. */
669675
#endif /* Use misc or X/Open. */
670676

lib/std/Build/Cache.zig

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -250,31 +250,28 @@ pub const HashHelper = struct {
250250
pub fn final(hh: *HashHelper) HexDigest {
251251
var bin_digest: BinDigest = undefined;
252252
hh.hasher.final(&bin_digest);
253-
254-
var out_digest: HexDigest = undefined;
255-
_ = fmt.bufPrint(
256-
&out_digest,
257-
"{s}",
258-
.{fmt.fmtSliceHexLower(&bin_digest)},
259-
) catch unreachable;
260-
return out_digest;
253+
return binToHex(bin_digest);
261254
}
262255

263256
pub fn oneShot(bytes: []const u8) [hex_digest_len]u8 {
264257
var hasher: Hasher = hasher_init;
265258
hasher.update(bytes);
266259
var bin_digest: BinDigest = undefined;
267260
hasher.final(&bin_digest);
268-
var out_digest: [hex_digest_len]u8 = undefined;
269-
_ = fmt.bufPrint(
270-
&out_digest,
271-
"{s}",
272-
.{fmt.fmtSliceHexLower(&bin_digest)},
273-
) catch unreachable;
274-
return out_digest;
261+
return binToHex(bin_digest);
275262
}
276263
};
277264

265+
pub fn binToHex(bin_digest: BinDigest) HexDigest {
266+
var out_digest: HexDigest = undefined;
267+
_ = fmt.bufPrint(
268+
&out_digest,
269+
"{s}",
270+
.{fmt.fmtSliceHexLower(&bin_digest)},
271+
) catch unreachable;
272+
return out_digest;
273+
}
274+
278275
pub const Lock = struct {
279276
manifest_file: fs.File,
280277

@@ -426,11 +423,7 @@ pub const Manifest = struct {
426423
var bin_digest: BinDigest = undefined;
427424
self.hash.hasher.final(&bin_digest);
428425

429-
_ = fmt.bufPrint(
430-
&self.hex_digest,
431-
"{s}",
432-
.{fmt.fmtSliceHexLower(&bin_digest)},
433-
) catch unreachable;
426+
self.hex_digest = binToHex(bin_digest);
434427

435428
self.hash.hasher = hasher_init;
436429
self.hash.hasher.update(&bin_digest);
@@ -899,14 +892,7 @@ pub const Manifest = struct {
899892
var bin_digest: BinDigest = undefined;
900893
self.hash.hasher.final(&bin_digest);
901894

902-
var out_digest: HexDigest = undefined;
903-
_ = fmt.bufPrint(
904-
&out_digest,
905-
"{s}",
906-
.{fmt.fmtSliceHexLower(&bin_digest)},
907-
) catch unreachable;
908-
909-
return out_digest;
895+
return binToHex(bin_digest);
910896
}
911897

912898
/// If `want_shared_lock` is true, this function automatically downgrades the

lib/std/Build/Module.zig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,18 @@ pub const IncludeDir = union(enum) {
137137
};
138138

139139
pub const LinkFrameworkOptions = struct {
140+
/// Causes dynamic libraries to be linked regardless of whether they are
141+
/// actually depended on. When false, dynamic libraries with no referenced
142+
/// symbols will be omitted by the linker.
140143
needed: bool = false,
144+
/// Marks all referenced symbols from this library as weak, meaning that if
145+
/// a same-named symbol is provided by another compilation unit, instead of
146+
/// emitting a "duplicate symbol" error, the linker will resolve all
147+
/// references to the symbol with the strong version.
148+
///
149+
/// When the linker encounters two weak symbols, the chosen one is
150+
/// determined by the order compilation units are provided to the linker,
151+
/// priority given to later ones.
141152
weak: bool = false,
142153
};
143154

@@ -414,7 +425,18 @@ pub fn iterateDependencies(
414425
}
415426

416427
pub const LinkSystemLibraryOptions = struct {
428+
/// Causes dynamic libraries to be linked regardless of whether they are
429+
/// actually depended on. When false, dynamic libraries with no referenced
430+
/// symbols will be omitted by the linker.
417431
needed: bool = false,
432+
/// Marks all referenced symbols from this library as weak, meaning that if
433+
/// a same-named symbol is provided by another compilation unit, instead of
434+
/// emitting a "duplicate symbol" error, the linker will resolve all
435+
/// references to the symbol with the strong version.
436+
///
437+
/// When the linker encounters two weak symbols, the chosen one is
438+
/// determined by the order compilation units are provided to the linker,
439+
/// priority given to later ones.
418440
weak: bool = false,
419441
use_pkg_config: SystemLib.UsePkgConfig = .yes,
420442
preferred_link_mode: std.builtin.LinkMode = .dynamic,
@@ -484,6 +506,7 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
484506
.flags = b.dupeStrings(options.flags),
485507
};
486508
m.link_objects.append(allocator, .{ .c_source_files = c_source_files }) catch @panic("OOM");
509+
addLazyPathDependenciesOnly(m, c_source_files.root);
487510
}
488511

489512
pub fn addCSourceFile(m: *Module, source: CSourceFile) void {

lib/std/Build/Step/Compile.zig

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,10 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking
989989
return path;
990990
}
991991

992-
fn make(step: *Step, prog_node: std.Progress.Node) !void {
992+
fn getZigArgs(compile: *Compile) ![][]const u8 {
993+
const step = &compile.step;
993994
const b = step.owner;
994995
const arena = b.allocator;
995-
const compile: *Compile = @fieldParentPtr("step", step);
996996

997997
var zig_args = ArrayList([]const u8).init(arena);
998998
defer zig_args.deinit();
@@ -1298,6 +1298,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
12981298
// We need to emit the --mod argument here so that the above link objects
12991299
// have the correct parent module, but only if the module is part of
13001300
// this compilation.
1301+
if (!my_responsibility) continue;
13011302
if (cli_named_modules.modules.getIndex(dep.module)) |module_cli_index| {
13021303
const module_cli_name = cli_named_modules.names.keys()[module_cli_index];
13031304
try dep.module.appendZigProcessFlags(&zig_args, step);
@@ -1724,7 +1725,16 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
17241725
try zig_args.append(resolved_args_file);
17251726
}
17261727

1727-
const maybe_output_bin_path = step.evalZigProcess(zig_args.items, prog_node) catch |err| switch (err) {
1728+
return try zig_args.toOwnedSlice();
1729+
}
1730+
1731+
fn make(step: *Step, prog_node: std.Progress.Node) !void {
1732+
const b = step.owner;
1733+
const compile: *Compile = @fieldParentPtr("step", step);
1734+
1735+
const zig_args = try getZigArgs(compile);
1736+
1737+
const maybe_output_bin_path = step.evalZigProcess(zig_args, prog_node) catch |err| switch (err) {
17281738
error.NeedCompileErrorCheck => {
17291739
assert(compile.expect_errors != null);
17301740
try checkCompileErrors(compile);

0 commit comments

Comments
 (0)