mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
cc: Add support for -Wp,
This commit is contained in:
parent
41330c96ae
commit
feaee2ba17
3 changed files with 39 additions and 1 deletions
|
|
@ -7472,7 +7472,7 @@ joinpd1("mtp="),
|
|||
.{
|
||||
.name = "Wp,",
|
||||
.syntax = .comma_joined,
|
||||
.zig_equivalent = .other,
|
||||
.zig_equivalent = .wp,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
|
|
|
|||
34
src/main.zig
34
src/main.zig
|
|
@ -1791,6 +1791,7 @@ fn buildOutputType(
|
|||
var c_out_mode: ?COutMode = null;
|
||||
var out_path: ?[]const u8 = null;
|
||||
var is_shared_lib = false;
|
||||
var preprocessor_args = std.ArrayList([]const u8).init(arena);
|
||||
var linker_args = std.ArrayList([]const u8).init(arena);
|
||||
var it = ClangArgIterator.init(arena, all_args);
|
||||
var emit_llvm = false;
|
||||
|
|
@ -1946,6 +1947,24 @@ fn buildOutputType(
|
|||
is_shared_lib = true;
|
||||
},
|
||||
.rdynamic => create_module.opts.rdynamic = true,
|
||||
.wp => {
|
||||
var split_it = mem.splitScalar(u8, it.only_arg, ',');
|
||||
while (split_it.next()) |preprocessor_arg| {
|
||||
if (preprocessor_arg.len >= 3 and
|
||||
preprocessor_arg[0] == '-' and
|
||||
preprocessor_arg[2] != '-')
|
||||
{
|
||||
if (mem.indexOfScalar(u8, preprocessor_arg, '=')) |equals_pos| {
|
||||
const key = preprocessor_arg[0..equals_pos];
|
||||
const value = preprocessor_arg[equals_pos + 1 ..];
|
||||
try preprocessor_args.append(key);
|
||||
try preprocessor_args.append(value);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try preprocessor_args.append(preprocessor_arg);
|
||||
}
|
||||
},
|
||||
.wl => {
|
||||
var split_it = mem.splitScalar(u8, it.only_arg, ',');
|
||||
while (split_it.next()) |linker_arg| {
|
||||
|
|
@ -2554,6 +2573,20 @@ fn buildOutputType(
|
|||
}
|
||||
}
|
||||
|
||||
// Parse preprocessor args.
|
||||
var preprocessor_args_it = ArgsIterator{
|
||||
.args = preprocessor_args.items,
|
||||
};
|
||||
while (preprocessor_args_it.next()) |arg| {
|
||||
if (mem.eql(u8, arg, "-MD") or mem.eql(u8, arg, "-MMD") or mem.eql(u8, arg, "-MT")) {
|
||||
disable_c_depfile = true;
|
||||
const cc_arg = try std.fmt.allocPrint(arena, "-Wp,{s},{s}", .{ arg, preprocessor_args_it.nextOrFatal() });
|
||||
try cc_argv.append(arena, cc_arg);
|
||||
} else {
|
||||
fatal("unsupported preprocessor arg: {s}", .{arg});
|
||||
}
|
||||
}
|
||||
|
||||
if (mod_opts.sanitize_c) |wsc| {
|
||||
if (wsc and mod_opts.optimize_mode == .ReleaseFast) {
|
||||
mod_opts.optimize_mode = .ReleaseSafe;
|
||||
|
|
@ -5771,6 +5804,7 @@ pub const ClangArgIterator = struct {
|
|||
shared,
|
||||
rdynamic,
|
||||
wl,
|
||||
wp,
|
||||
preprocess_only,
|
||||
asm_only,
|
||||
optimize,
|
||||
|
|
|
|||
|
|
@ -154,6 +154,10 @@ const known_options = [_]KnownOpt{
|
|||
.name = "Wl,",
|
||||
.ident = "wl",
|
||||
},
|
||||
.{
|
||||
.name = "Wp,",
|
||||
.ident = "wp",
|
||||
},
|
||||
.{
|
||||
.name = "Xlinker",
|
||||
.ident = "for_linker",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue