From a038ef3570caed01815173d95089e016fab3a050 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 11 May 2019 21:06:31 +0200 Subject: Assemble asm files using CC Stuffing all the files together and compiling the resulting blob with the main program is a terrible idea. Some files, namely the .S ones, must be run trough the C preprocessor before assembling them (#2437). Beside that the aggregate may be mis-compiled due to the presence of some flags that affect the following code. For example let's consider two files, a.s and b.s a.s ``` fn1: ret .data data1: .word 0 ``` b.s ``` fn2: ret ``` Now, fn1 and fn2 will be both placed in the .text section as intended if the two files are compiled separately. But if we merge them the `.data` flag ends up placing fn2 in the wrong section! This fixes a nasty crash where musl's memset ended up in the non-executable data segment, leading to too many hours of head-scratching. --- std/build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'std/build.zig') diff --git a/std/build.zig b/std/build.zig index b5ec97ab5f..ff64c6cb93 100644 --- a/std/build.zig +++ b/std/build.zig @@ -1376,7 +1376,7 @@ pub const LibExeObjStep = struct { try zig_args.append(name); }, LinkObject.AssemblyFile => |asm_file| { - try zig_args.append("--assembly"); + try zig_args.append("--c-source"); try zig_args.append(builder.pathFromRoot(asm_file)); }, LinkObject.CSourceFile => |c_source_file| { -- cgit v1.2.3