mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.builtin: make link mode fields lowercase
This commit is contained in:
parent
099f3c4039
commit
9d70d614ae
35 changed files with 159 additions and 164 deletions
|
|
@ -855,7 +855,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
|
|||
}
|
||||
|
||||
const CMakeConfig = struct {
|
||||
llvm_linkage: std.Build.Step.Compile.Linkage,
|
||||
llvm_linkage: std.builtin.LinkMode,
|
||||
cmake_binary_dir: []const u8,
|
||||
cmake_prefix_path: []const u8,
|
||||
cmake_static_library_prefix: []const u8,
|
||||
|
|
|
|||
20
lib/c.zig
20
lib/c.zig
|
|
@ -26,7 +26,7 @@ const is_freestanding = switch (native_os) {
|
|||
|
||||
comptime {
|
||||
if (is_freestanding and is_wasm and builtin.link_libc) {
|
||||
@export(wasm_start, .{ .name = "_start", .linkage = .Strong });
|
||||
@export(wasm_start, .{ .name = "_start", .linkage = .strong });
|
||||
}
|
||||
|
||||
if (native_os == .linux) {
|
||||
|
|
@ -34,16 +34,16 @@ comptime {
|
|||
}
|
||||
|
||||
if (builtin.link_libc) {
|
||||
@export(strcmp, .{ .name = "strcmp", .linkage = .Strong });
|
||||
@export(strncmp, .{ .name = "strncmp", .linkage = .Strong });
|
||||
@export(strerror, .{ .name = "strerror", .linkage = .Strong });
|
||||
@export(strlen, .{ .name = "strlen", .linkage = .Strong });
|
||||
@export(strcpy, .{ .name = "strcpy", .linkage = .Strong });
|
||||
@export(strncpy, .{ .name = "strncpy", .linkage = .Strong });
|
||||
@export(strcat, .{ .name = "strcat", .linkage = .Strong });
|
||||
@export(strncat, .{ .name = "strncat", .linkage = .Strong });
|
||||
@export(strcmp, .{ .name = "strcmp", .linkage = .strong });
|
||||
@export(strncmp, .{ .name = "strncmp", .linkage = .strong });
|
||||
@export(strerror, .{ .name = "strerror", .linkage = .strong });
|
||||
@export(strlen, .{ .name = "strlen", .linkage = .strong });
|
||||
@export(strcpy, .{ .name = "strcpy", .linkage = .strong });
|
||||
@export(strncpy, .{ .name = "strncpy", .linkage = .strong });
|
||||
@export(strcat, .{ .name = "strcat", .linkage = .strong });
|
||||
@export(strncat, .{ .name = "strncat", .linkage = .strong });
|
||||
} else if (is_msvc) {
|
||||
@export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
|
||||
@export(_fltused, .{ .name = "_fltused", .linkage = .strong });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const builtin = @import("builtin");
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak;
|
||||
const panic = @import("common.zig").panic;
|
||||
|
||||
const have_availability_version_check = builtin.os.tag.isDarwin() and
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ const is_test = builtin.is_test;
|
|||
const is_gnu = abi.isGnu();
|
||||
const is_mingw = os_tag == .windows and is_gnu;
|
||||
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong;
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak;
|
||||
const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .strong;
|
||||
pub const panic = @import("common.zig").panic;
|
||||
|
||||
comptime {
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ pub const ExecutableOptions = struct {
|
|||
version: ?std.SemanticVersion = null,
|
||||
optimize: std.builtin.OptimizeMode = .Debug,
|
||||
code_model: std.builtin.CodeModel = .default,
|
||||
linkage: ?Step.Compile.Linkage = null,
|
||||
linkage: ?std.builtin.LinkMode = null,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ pub const LinkSystemLibraryOptions = struct {
|
|||
needed: bool = false,
|
||||
weak: bool = false,
|
||||
use_pkg_config: SystemLib.UsePkgConfig = .yes,
|
||||
preferred_link_mode: std.builtin.LinkMode = .Dynamic,
|
||||
preferred_link_mode: std.builtin.LinkMode = .dynamic,
|
||||
search_strategy: SystemLib.SearchStrategy = .paths_first,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ linker_script: ?LazyPath = null,
|
|||
version_script: ?LazyPath = null,
|
||||
out_filename: []const u8,
|
||||
out_lib_filename: []const u8,
|
||||
linkage: ?Linkage = null,
|
||||
linkage: ?std.builtin.LinkMode = null,
|
||||
version: ?std.SemanticVersion,
|
||||
kind: Kind,
|
||||
major_only_filename: ?[]const u8,
|
||||
|
|
@ -223,7 +223,7 @@ pub const Options = struct {
|
|||
name: []const u8,
|
||||
root_module: Module.CreateOptions,
|
||||
kind: Kind,
|
||||
linkage: ?Linkage = null,
|
||||
linkage: ?std.builtin.LinkMode = null,
|
||||
version: ?std.SemanticVersion = null,
|
||||
max_rss: usize = 0,
|
||||
filters: []const []const u8 = &.{},
|
||||
|
|
@ -246,8 +246,6 @@ pub const Kind = enum {
|
|||
@"test",
|
||||
};
|
||||
|
||||
pub const Linkage = enum { dynamic, static };
|
||||
|
||||
pub fn create(owner: *std.Build, options: Options) *Compile {
|
||||
const name = owner.dupe(options.name);
|
||||
if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
|
||||
|
|
@ -283,10 +281,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
|
|||
.obj => .Obj,
|
||||
.exe, .@"test" => .Exe,
|
||||
},
|
||||
.link_mode = if (options.linkage) |some| @as(std.builtin.LinkMode, switch (some) {
|
||||
.dynamic => .Dynamic,
|
||||
.static => .Static,
|
||||
}) else null,
|
||||
.link_mode = options.linkage,
|
||||
.version = options.version,
|
||||
}) catch @panic("OOM");
|
||||
|
||||
|
|
@ -531,11 +526,11 @@ pub fn dependsOnSystemLibrary(self: *const Compile, name: []const u8) bool {
|
|||
}
|
||||
|
||||
pub fn isDynamicLibrary(self: *const Compile) bool {
|
||||
return self.kind == .lib and self.linkage == Linkage.dynamic;
|
||||
return self.kind == .lib and self.linkage == .dynamic;
|
||||
}
|
||||
|
||||
pub fn isStaticLibrary(self: *const Compile) bool {
|
||||
return self.kind == .lib and self.linkage != Linkage.dynamic;
|
||||
return self.kind == .lib and self.linkage != .dynamic;
|
||||
}
|
||||
|
||||
pub fn producesPdbFile(self: *Compile) bool {
|
||||
|
|
@ -988,7 +983,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
|||
var prev_has_cflags = false;
|
||||
var prev_has_rcflags = false;
|
||||
var prev_search_strategy: Module.SystemLib.SearchStrategy = .paths_first;
|
||||
var prev_preferred_link_mode: std.builtin.LinkMode = .Dynamic;
|
||||
var prev_preferred_link_mode: std.builtin.LinkMode = .dynamic;
|
||||
// Track the number of positional arguments so that a nice error can be
|
||||
// emitted if there is nothing to link.
|
||||
var total_linker_objects: usize = @intFromBool(self.root_module.root_source_file != null);
|
||||
|
|
@ -1053,16 +1048,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
|||
{
|
||||
switch (system_lib.search_strategy) {
|
||||
.no_fallback => switch (system_lib.preferred_link_mode) {
|
||||
.Dynamic => try zig_args.append("-search_dylibs_only"),
|
||||
.Static => try zig_args.append("-search_static_only"),
|
||||
.dynamic => try zig_args.append("-search_dylibs_only"),
|
||||
.static => try zig_args.append("-search_static_only"),
|
||||
},
|
||||
.paths_first => switch (system_lib.preferred_link_mode) {
|
||||
.Dynamic => try zig_args.append("-search_paths_first"),
|
||||
.Static => try zig_args.append("-search_paths_first_static"),
|
||||
.dynamic => try zig_args.append("-search_paths_first"),
|
||||
.static => try zig_args.append("-search_paths_first_static"),
|
||||
},
|
||||
.mode_first => switch (system_lib.preferred_link_mode) {
|
||||
.Dynamic => try zig_args.append("-search_dylibs_first"),
|
||||
.Static => try zig_args.append("-search_static_first"),
|
||||
.dynamic => try zig_args.append("-search_dylibs_first"),
|
||||
.static => try zig_args.append("-search_static_first"),
|
||||
},
|
||||
}
|
||||
prev_search_strategy = system_lib.search_strategy;
|
||||
|
|
@ -1138,7 +1133,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
|||
try zig_args.append(full_path_lib);
|
||||
total_linker_objects += 1;
|
||||
|
||||
if (other.linkage == Linkage.dynamic and
|
||||
if (other.linkage == .dynamic and
|
||||
self.rootModuleTarget().os.tag != .windows)
|
||||
{
|
||||
if (fs.path.dirname(full_path_lib)) |dirname| {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub const AddExecutableOptions = struct {
|
|||
version: ?std.SemanticVersion = null,
|
||||
target: ?std.Build.ResolvedTarget = null,
|
||||
optimize: ?std.builtin.OptimizeMode = null,
|
||||
linkage: ?Step.Compile.Linkage = null,
|
||||
linkage: ?std.builtin.LinkMode = null,
|
||||
};
|
||||
|
||||
pub fn getOutput(self: *TranslateC) std.Build.LazyPath {
|
||||
|
|
|
|||
|
|
@ -500,8 +500,8 @@ pub const OutputMode = enum {
|
|||
/// This data structure is used by the Zig language code generation and
|
||||
/// therefore must be kept in sync with the compiler implementation.
|
||||
pub const LinkMode = enum {
|
||||
Static,
|
||||
Dynamic,
|
||||
static,
|
||||
dynamic,
|
||||
};
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ var dummy_execute_header: mach_hdr = undefined;
|
|||
pub extern var _mh_execute_header: mach_hdr;
|
||||
comptime {
|
||||
if (builtin.target.isDarwin()) {
|
||||
@export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .Weak });
|
||||
@export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ const RDebug = extern struct {
|
|||
/// TODO make it possible to reference this same external symbol 2x so we don't need this
|
||||
/// helper function.
|
||||
pub fn get_DYNAMIC() ?[*]elf.Dyn {
|
||||
return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .Weak });
|
||||
return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .weak });
|
||||
}
|
||||
|
||||
pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ const extern_getauxval = switch (builtin.zig_backend) {
|
|||
|
||||
comptime {
|
||||
if (extern_getauxval) {
|
||||
@export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak });
|
||||
@export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ comptime {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) {
|
||||
if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {
|
||||
if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
|
||||
@export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,9 +155,9 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
|
|||
.coff => switch (options.output_mode) {
|
||||
.Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }),
|
||||
.Lib => {
|
||||
const suffix = switch (options.link_mode orelse .Static) {
|
||||
.Static => ".lib",
|
||||
.Dynamic => ".dll",
|
||||
const suffix = switch (options.link_mode orelse .static) {
|
||||
.static => ".lib",
|
||||
.dynamic => ".dll",
|
||||
};
|
||||
return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, suffix });
|
||||
},
|
||||
|
|
@ -166,11 +166,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
|
|||
.elf => switch (options.output_mode) {
|
||||
.Exe => return allocator.dupe(u8, root_name),
|
||||
.Lib => {
|
||||
switch (options.link_mode orelse .Static) {
|
||||
.Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
|
||||
switch (options.link_mode orelse .static) {
|
||||
.static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
|
||||
t.libPrefix(), root_name,
|
||||
}),
|
||||
.Dynamic => {
|
||||
.dynamic => {
|
||||
if (options.version) |ver| {
|
||||
return std.fmt.allocPrint(allocator, "{s}{s}.so.{d}.{d}.{d}", .{
|
||||
t.libPrefix(), root_name, ver.major, ver.minor, ver.patch,
|
||||
|
|
@ -188,11 +188,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
|
|||
.macho => switch (options.output_mode) {
|
||||
.Exe => return allocator.dupe(u8, root_name),
|
||||
.Lib => {
|
||||
switch (options.link_mode orelse .Static) {
|
||||
.Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
|
||||
switch (options.link_mode orelse .static) {
|
||||
.static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
|
||||
t.libPrefix(), root_name,
|
||||
}),
|
||||
.Dynamic => {
|
||||
.dynamic => {
|
||||
if (options.version) |ver| {
|
||||
return std.fmt.allocPrint(allocator, "{s}{s}.{d}.{d}.{d}.dylib", .{
|
||||
t.libPrefix(), root_name, ver.major, ver.minor, ver.patch,
|
||||
|
|
@ -210,11 +210,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
|
|||
.wasm => switch (options.output_mode) {
|
||||
.Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }),
|
||||
.Lib => {
|
||||
switch (options.link_mode orelse .Static) {
|
||||
.Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
|
||||
switch (options.link_mode orelse .static) {
|
||||
.static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
|
||||
t.libPrefix(), root_name,
|
||||
}),
|
||||
.Dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}),
|
||||
.dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}),
|
||||
}
|
||||
},
|
||||
.Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),
|
||||
|
|
|
|||
|
|
@ -1201,7 +1201,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
|
|||
const output_mode = options.config.output_mode;
|
||||
const is_dyn_lib = switch (output_mode) {
|
||||
.Obj, .Exe => false,
|
||||
.Lib => options.config.link_mode == .Dynamic,
|
||||
.Lib => options.config.link_mode == .dynamic,
|
||||
};
|
||||
const is_exe_or_dyn_lib = switch (output_mode) {
|
||||
.Obj => false,
|
||||
|
|
@ -1806,8 +1806,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
|
|||
.{ .musl_crt_file = .scrt1_o },
|
||||
.{ .musl_crt_file = .rcrt1_o },
|
||||
switch (comp.config.link_mode) {
|
||||
.Static => .{ .musl_crt_file = .libc_a },
|
||||
.Dynamic => .{ .musl_crt_file = .libc_so },
|
||||
.static => .{ .musl_crt_file = .libc_a },
|
||||
.dynamic => .{ .musl_crt_file = .libc_so },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -6087,7 +6087,7 @@ pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const
|
|||
fn wantBuildLibCFromSource(comp: Compilation) bool {
|
||||
const is_exe_or_dyn_lib = switch (comp.config.output_mode) {
|
||||
.Obj => false,
|
||||
.Lib => comp.config.link_mode == .Dynamic,
|
||||
.Lib => comp.config.link_mode == .dynamic,
|
||||
.Exe => true,
|
||||
};
|
||||
const ofmt = comp.root_mod.resolved_target.result.ofmt;
|
||||
|
|
@ -6116,7 +6116,7 @@ fn wantBuildMinGWFromSource(comp: Compilation) bool {
|
|||
fn wantBuildLibUnwindFromSource(comp: *Compilation) bool {
|
||||
const is_exe_or_dyn_lib = switch (comp.config.output_mode) {
|
||||
.Obj => false,
|
||||
.Lib => comp.config.link_mode == .Dynamic,
|
||||
.Lib => comp.config.link_mode == .dynamic,
|
||||
.Exe => true,
|
||||
};
|
||||
const ofmt = comp.root_mod.resolved_target.result.ofmt;
|
||||
|
|
@ -6310,7 +6310,7 @@ fn buildOutputFromZig(
|
|||
|
||||
const config = try Config.resolve(.{
|
||||
.output_mode = output_mode,
|
||||
.link_mode = .Static,
|
||||
.link_mode = .static,
|
||||
.resolved_target = comp.root_mod.resolved_target,
|
||||
.is_test = false,
|
||||
.have_zcu = true,
|
||||
|
|
|
|||
|
|
@ -348,26 +348,26 @@ pub fn resolve(options: Options) ResolveError!Config {
|
|||
const link_mode = b: {
|
||||
const explicitly_exe_or_dyn_lib = switch (options.output_mode) {
|
||||
.Obj => false,
|
||||
.Lib => (options.link_mode orelse .Static) == .Dynamic,
|
||||
.Lib => (options.link_mode orelse .static) == .dynamic,
|
||||
.Exe => true,
|
||||
};
|
||||
|
||||
if (target_util.cannotDynamicLink(target)) {
|
||||
if (options.link_mode == .Dynamic) return error.TargetCannotDynamicLink;
|
||||
break :b .Static;
|
||||
if (options.link_mode == .dynamic) return error.TargetCannotDynamicLink;
|
||||
break :b .static;
|
||||
}
|
||||
if (explicitly_exe_or_dyn_lib and link_libc and
|
||||
(target.isGnuLibC() or target_util.osRequiresLibC(target)))
|
||||
{
|
||||
if (options.link_mode == .Static) return error.LibCRequiresDynamicLinking;
|
||||
break :b .Dynamic;
|
||||
if (options.link_mode == .static) return error.LibCRequiresDynamicLinking;
|
||||
break :b .dynamic;
|
||||
}
|
||||
// When creating a executable that links to system libraries, we
|
||||
// require dynamic linking, but we must not link static libraries
|
||||
// or object files dynamically!
|
||||
if (options.any_dyn_libs and options.output_mode == .Exe) {
|
||||
if (options.link_mode == .Static) return error.SharedLibrariesRequireDynamicLinking;
|
||||
break :b .Dynamic;
|
||||
if (options.link_mode == .static) return error.SharedLibrariesRequireDynamicLinking;
|
||||
break :b .dynamic;
|
||||
}
|
||||
|
||||
if (options.link_mode) |link_mode| break :b link_mode;
|
||||
|
|
@ -377,16 +377,16 @@ pub fn resolve(options: Options) ResolveError!Config {
|
|||
{
|
||||
// If targeting the system's native ABI and the system's libc is
|
||||
// musl, link dynamically by default.
|
||||
break :b .Dynamic;
|
||||
break :b .dynamic;
|
||||
}
|
||||
|
||||
// Static is generally a better default. Fight me.
|
||||
break :b .Static;
|
||||
break :b .static;
|
||||
};
|
||||
|
||||
const import_memory = options.import_memory orelse (options.output_mode == .Obj);
|
||||
const export_memory = b: {
|
||||
if (link_mode == .Dynamic) {
|
||||
if (link_mode == .dynamic) {
|
||||
if (options.export_memory == true) return error.ExportMemoryAndDynamicIncompatible;
|
||||
break :b false;
|
||||
}
|
||||
|
|
@ -397,7 +397,7 @@ pub fn resolve(options: Options) ResolveError!Config {
|
|||
const pie: bool = b: {
|
||||
switch (options.output_mode) {
|
||||
.Obj, .Exe => {},
|
||||
.Lib => if (link_mode == .Dynamic) {
|
||||
.Lib => if (link_mode == .dynamic) {
|
||||
if (options.pie == true) return error.DynamicLibraryPrecludesPie;
|
||||
break :b false;
|
||||
},
|
||||
|
|
@ -467,7 +467,7 @@ pub fn resolve(options: Options) ResolveError!Config {
|
|||
if (rdynamic) break :b true;
|
||||
break :b switch (options.output_mode) {
|
||||
.Obj, .Exe => false,
|
||||
.Lib => link_mode == .Dynamic,
|
||||
.Lib => link_mode == .dynamic,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
|
|||
return error.PieRequiresPic;
|
||||
break :b true;
|
||||
}
|
||||
if (options.global.link_mode == .Dynamic) {
|
||||
if (options.global.link_mode == .dynamic) {
|
||||
if (options.inherited.pic == false)
|
||||
return error.DynamicLinkingRequiresPic;
|
||||
break :b true;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ pub fn emitMir(emit: *Emit) Error!void {
|
|||
const is_obj_or_static_lib = switch (emit.lower.output_mode) {
|
||||
.Exe => false,
|
||||
.Obj => true,
|
||||
.Lib => emit.lower.link_mode == .Static,
|
||||
.Lib => emit.lower.link_mode == .static,
|
||||
};
|
||||
const atom = elf_file.symbol(data.atom_index).atom(elf_file).?;
|
||||
const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index);
|
||||
|
|
@ -158,7 +158,7 @@ pub fn emitMir(emit: *Emit) Error!void {
|
|||
const is_obj_or_static_lib = switch (emit.lower.output_mode) {
|
||||
.Exe => false,
|
||||
.Obj => true,
|
||||
.Lib => emit.lower.link_mode == .Static,
|
||||
.Lib => emit.lower.link_mode == .static,
|
||||
};
|
||||
const atom = macho_file.getSymbol(data.atom_index).getAtom(macho_file).?;
|
||||
const sym_index = macho_file.getZigObject().?.symbols.items[data.sym_index];
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
|||
const is_obj_or_static_lib = switch (lower.output_mode) {
|
||||
.Exe => false,
|
||||
.Obj => true,
|
||||
.Lib => lower.link_mode == .Static,
|
||||
.Lib => lower.link_mode == .static,
|
||||
};
|
||||
|
||||
const emit_prefix = prefix;
|
||||
|
|
|
|||
|
|
@ -1084,7 +1084,7 @@ fn buildSharedLib(
|
|||
const strip = comp.compilerRtStrip();
|
||||
const config = try Compilation.Config.resolve(.{
|
||||
.output_mode = .Lib,
|
||||
.link_mode = .Dynamic,
|
||||
.link_mode = .dynamic,
|
||||
.resolved_target = comp.root_mod.resolved_target,
|
||||
.is_test = false,
|
||||
.have_zcu = false,
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
|||
|
||||
const root_name = "c++";
|
||||
const output_mode = .Lib;
|
||||
const link_mode = .Static;
|
||||
const link_mode = .static;
|
||||
const target = comp.root_mod.resolved_target.result;
|
||||
const basename = try std.zig.binNameAlloc(arena, .{
|
||||
.root_name = root_name,
|
||||
|
|
@ -327,7 +327,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
|||
|
||||
const root_name = "c++abi";
|
||||
const output_mode = .Lib;
|
||||
const link_mode = .Static;
|
||||
const link_mode = .static;
|
||||
const target = comp.root_mod.resolved_target.result;
|
||||
const basename = try std.zig.binNameAlloc(arena, .{
|
||||
.root_name = root_name,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v
|
|||
|
||||
const root_name = "tsan";
|
||||
const output_mode = .Lib;
|
||||
const link_mode = .Static;
|
||||
const link_mode = .static;
|
||||
const target = comp.getTarget();
|
||||
const basename = try std.zig.binNameAlloc(arena, .{
|
||||
.root_name = root_name,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
|||
});
|
||||
|
||||
const root_name = "unwind";
|
||||
const link_mode = .Static;
|
||||
const link_mode = .static;
|
||||
const target = comp.root_mod.resolved_target.result;
|
||||
const basename = try std.zig.binNameAlloc(arena, .{
|
||||
.root_name = root_name,
|
||||
|
|
|
|||
12
src/link.zig
12
src/link.zig
|
|
@ -287,8 +287,8 @@ pub const File = struct {
|
|||
switch (output_mode) {
|
||||
.Obj => return,
|
||||
.Lib => switch (link_mode) {
|
||||
.Static => return,
|
||||
.Dynamic => {},
|
||||
.static => return,
|
||||
.dynamic => {},
|
||||
},
|
||||
.Exe => {},
|
||||
}
|
||||
|
|
@ -582,7 +582,7 @@ pub const File = struct {
|
|||
const use_lld = build_options.have_llvm and comp.config.use_lld;
|
||||
const output_mode = comp.config.output_mode;
|
||||
const link_mode = comp.config.link_mode;
|
||||
if (use_lld and output_mode == .Lib and link_mode == .Static) {
|
||||
if (use_lld and output_mode == .Lib and link_mode == .static) {
|
||||
return base.linkAsArchive(arena, prog_node);
|
||||
}
|
||||
switch (base.tag) {
|
||||
|
|
@ -957,8 +957,8 @@ pub const File = struct {
|
|||
const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777;
|
||||
switch (effectiveOutputMode(use_lld, output_mode)) {
|
||||
.Lib => return switch (link_mode) {
|
||||
.Dynamic => executable_mode,
|
||||
.Static => fs.File.default_mode,
|
||||
.dynamic => executable_mode,
|
||||
.static => fs.File.default_mode,
|
||||
},
|
||||
.Exe => return executable_mode,
|
||||
.Obj => return fs.File.default_mode,
|
||||
|
|
@ -966,7 +966,7 @@ pub const File = struct {
|
|||
}
|
||||
|
||||
pub fn isStatic(self: File) bool {
|
||||
return self.comp.config.link_mode == .Static;
|
||||
return self.comp.config.link_mode == .static;
|
||||
}
|
||||
|
||||
pub fn isObject(self: File) bool {
|
||||
|
|
|
|||
|
|
@ -2275,7 +2275,7 @@ fn writeHeader(self: *Coff) !void {
|
|||
.p32 => flags.@"32BIT_MACHINE" = 1,
|
||||
.p64 => flags.LARGE_ADDRESS_AWARE = 1,
|
||||
}
|
||||
if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .Dynamic) {
|
||||
if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .dynamic) {
|
||||
flags.DLL = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)
|
|||
defer sub_prog_node.end();
|
||||
|
||||
const is_lib = comp.config.output_mode == .Lib;
|
||||
const is_dyn_lib = comp.config.link_mode == .Dynamic and is_lib;
|
||||
const is_dyn_lib = comp.config.link_mode == .dynamic and is_lib;
|
||||
const is_exe_or_dyn_lib = is_dyn_lib or comp.config.output_mode == .Exe;
|
||||
const link_in_crt = comp.config.link_libc and is_exe_or_dyn_lib;
|
||||
const target = comp.root_mod.resolved_target.result;
|
||||
|
|
@ -411,16 +411,16 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)
|
|||
try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib"));
|
||||
} else {
|
||||
const lib_str = switch (comp.config.link_mode) {
|
||||
.Dynamic => "",
|
||||
.Static => "lib",
|
||||
.dynamic => "",
|
||||
.static => "lib",
|
||||
};
|
||||
const d_str = switch (optimize_mode) {
|
||||
.Debug => "d",
|
||||
else => "",
|
||||
};
|
||||
switch (comp.config.link_mode) {
|
||||
.Static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})),
|
||||
.Dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})),
|
||||
.static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})),
|
||||
.dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})),
|
||||
}
|
||||
|
||||
try argv.append(try allocPrint(arena, "{s}vcruntime{s}.lib", .{ lib_str, d_str }));
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ pub fn createEmpty(
|
|||
.sparc64 => 0x2000,
|
||||
else => 0x1000,
|
||||
};
|
||||
const is_dyn_lib = output_mode == .Lib and link_mode == .Dynamic;
|
||||
const is_dyn_lib = output_mode == .Lib and link_mode == .dynamic;
|
||||
const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or comp.config.rdynamic)
|
||||
elf.VER_NDX_GLOBAL
|
||||
else
|
||||
|
|
@ -349,7 +349,7 @@ pub fn createEmpty(
|
|||
}
|
||||
|
||||
const is_obj = output_mode == .Obj;
|
||||
const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .Static);
|
||||
const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .static);
|
||||
|
||||
// What path should this ELF linker code output to?
|
||||
// If using LLD to link, this code should produce an object file so that it
|
||||
|
|
@ -1180,10 +1180,10 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node)
|
|||
|
||||
success: {
|
||||
if (!self.base.isStatic()) {
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Dynamic))
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .dynamic))
|
||||
break :success;
|
||||
}
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Static))
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .static))
|
||||
break :success;
|
||||
|
||||
try self.reportMissingLibraryError(
|
||||
|
|
@ -1211,8 +1211,8 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node)
|
|||
});
|
||||
} else if (target.isMusl()) {
|
||||
const path = try comp.get_libc_crt_file(arena, switch (link_mode) {
|
||||
.Static => "libc.a",
|
||||
.Dynamic => "libc.so",
|
||||
.static => "libc.a",
|
||||
.dynamic => "libc.so",
|
||||
});
|
||||
try system_libs.append(.{ .path = path });
|
||||
} else {
|
||||
|
|
@ -1628,7 +1628,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
|
|||
// libc dep
|
||||
if (comp.config.link_libc) {
|
||||
if (self.base.comp.libc_installation != null) {
|
||||
const needs_grouping = link_mode == .Static;
|
||||
const needs_grouping = link_mode == .static;
|
||||
if (needs_grouping) try argv.append("--start-group");
|
||||
try argv.appendSlice(target_util.libcFullLinkFlags(target));
|
||||
if (needs_grouping) try argv.append("--end-group");
|
||||
|
|
@ -1642,8 +1642,8 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
|
|||
try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a"));
|
||||
} else if (target.isMusl()) {
|
||||
try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) {
|
||||
.Static => "libc.a",
|
||||
.Dynamic => "libc.so",
|
||||
.static => "libc.a",
|
||||
.dynamic => "libc.so",
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -1797,10 +1797,10 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void {
|
|||
// Maybe we should hoist search-strategy all the way here?
|
||||
for (self.lib_dirs) |lib_dir| {
|
||||
if (!self.base.isStatic()) {
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Dynamic))
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .dynamic))
|
||||
break :success;
|
||||
}
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Static))
|
||||
if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .static))
|
||||
break :success;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1858,8 +1858,8 @@ fn accessLibPath(
|
|||
test_path.clearRetainingCapacity();
|
||||
const prefix = if (link_mode != null) "lib" else "";
|
||||
const suffix = if (link_mode) |mode| switch (mode) {
|
||||
.Static => target.staticLibSuffix(),
|
||||
.Dynamic => target.dynamicLibSuffix(),
|
||||
.static => target.staticLibSuffix(),
|
||||
.dynamic => target.dynamicLibSuffix(),
|
||||
} else "";
|
||||
try test_path.writer().print("{s}" ++ sep ++ "{s}{s}{s}", .{
|
||||
lib_dir_path,
|
||||
|
|
@ -2150,10 +2150,10 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
|
|||
const is_obj = output_mode == .Obj;
|
||||
const is_lib = output_mode == .Lib;
|
||||
const link_mode = comp.config.link_mode;
|
||||
const is_dyn_lib = link_mode == .Dynamic and is_lib;
|
||||
const is_dyn_lib = link_mode == .dynamic and is_lib;
|
||||
const is_exe_or_dyn_lib = is_dyn_lib or output_mode == .Exe;
|
||||
const have_dynamic_linker = comp.config.link_libc and
|
||||
link_mode == .Dynamic and is_exe_or_dyn_lib;
|
||||
link_mode == .dynamic and is_exe_or_dyn_lib;
|
||||
const target = comp.root_mod.resolved_target.result;
|
||||
const compiler_rt_path: ?[]const u8 = blk: {
|
||||
if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
|
||||
|
|
@ -2463,7 +2463,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
|
|||
try argv.append(arg);
|
||||
}
|
||||
|
||||
if (link_mode == .Static) {
|
||||
if (link_mode == .static) {
|
||||
if (target.cpu.arch.isArmOrThumb()) {
|
||||
try argv.append("-Bstatic");
|
||||
} else {
|
||||
|
|
@ -2647,7 +2647,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
|
|||
comp.link_error_flags.missing_libc = false;
|
||||
if (comp.config.link_libc) {
|
||||
if (comp.libc_installation != null) {
|
||||
const needs_grouping = link_mode == .Static;
|
||||
const needs_grouping = link_mode == .static;
|
||||
if (needs_grouping) try argv.append("--start-group");
|
||||
try argv.appendSlice(target_util.libcFullLinkFlags(target));
|
||||
if (needs_grouping) try argv.append("--end-group");
|
||||
|
|
@ -2661,8 +2661,8 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
|
|||
try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a"));
|
||||
} else if (target.isMusl()) {
|
||||
try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) {
|
||||
.Static => "libc.a",
|
||||
.Dynamic => "libc.so",
|
||||
.static => "libc.a",
|
||||
.dynamic => "libc.so",
|
||||
}));
|
||||
} else {
|
||||
comp.link_error_flags.missing_libc = true;
|
||||
|
|
@ -2928,8 +2928,8 @@ pub fn writeElfHeader(self: *Elf) !void {
|
|||
.Exe => if (comp.config.pie) .DYN else .EXEC,
|
||||
.Obj => .REL,
|
||||
.Lib => switch (link_mode) {
|
||||
.Static => @as(elf.ET, .REL),
|
||||
.Dynamic => .DYN,
|
||||
.static => @as(elf.ET, .REL),
|
||||
.dynamic => .DYN,
|
||||
},
|
||||
};
|
||||
mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian);
|
||||
|
|
@ -3216,7 +3216,7 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void {
|
|||
|
||||
// __rela_iplt_start, __rela_iplt_end
|
||||
if (self.rela_dyn_section_index) |shndx| blk: {
|
||||
if (link_mode != .Static or comp.config.pie) break :blk;
|
||||
if (link_mode != .static or comp.config.pie) break :blk;
|
||||
const shdr = &self.shdrs.items[shndx];
|
||||
const end_addr = shdr.sh_addr + shdr.sh_size;
|
||||
const start_addr = end_addr - self.calcNumIRelativeRelocs() * @sizeOf(elf.Elf64_Rela);
|
||||
|
|
@ -5061,12 +5061,12 @@ const CsuObjects = struct {
|
|||
} = switch (comp.config.output_mode) {
|
||||
.Obj => return CsuObjects{},
|
||||
.Lib => switch (comp.config.link_mode) {
|
||||
.Dynamic => .dynamic_lib,
|
||||
.Static => return CsuObjects{},
|
||||
.dynamic => .dynamic_lib,
|
||||
.static => return CsuObjects{},
|
||||
},
|
||||
.Exe => switch (comp.config.link_mode) {
|
||||
.Dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe,
|
||||
.Static => if (comp.config.pie) .static_pie else .static_exe,
|
||||
.dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe,
|
||||
.static => if (comp.config.pie) .static_pie else .static_exe,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ pub fn writeDylibLC(ctx: WriteDylibLCCtx, writer: anytype) !void {
|
|||
pub fn writeDylibIdLC(macho_file: *MachO, writer: anytype) !void {
|
||||
const comp = macho_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
assert(comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic);
|
||||
assert(comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic);
|
||||
const emit = macho_file.base.emit;
|
||||
const install_name = macho_file.install_name orelse
|
||||
try emit.directory.join(gpa, &.{emit.sub_path});
|
||||
|
|
|
|||
|
|
@ -2518,7 +2518,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node)
|
|||
// When the target os is WASI, we allow linking with WASI-LIBC
|
||||
if (target.os.tag == .wasi) {
|
||||
const is_exe_or_dyn_lib = output_mode == .Exe or
|
||||
(output_mode == .Lib and link_mode == .Dynamic);
|
||||
(output_mode == .Lib and link_mode == .dynamic);
|
||||
if (is_exe_or_dyn_lib) {
|
||||
for (comp.wasi_emulated_libs) |crt_file| {
|
||||
try positionals.append(try comp.get_libc_crt_file(
|
||||
|
|
@ -3549,7 +3549,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo
|
|||
try argv.append("--allow-undefined");
|
||||
}
|
||||
|
||||
if (comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic) {
|
||||
if (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic) {
|
||||
try argv.append("--shared");
|
||||
}
|
||||
if (comp.config.pie) {
|
||||
|
|
@ -3569,7 +3569,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo
|
|||
|
||||
if (target.os.tag == .wasi) {
|
||||
const is_exe_or_dyn_lib = comp.config.output_mode == .Exe or
|
||||
(comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic);
|
||||
(comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic);
|
||||
if (is_exe_or_dyn_lib) {
|
||||
for (comp.wasi_emulated_libs) |crt_file| {
|
||||
try argv.append(try comp.get_libc_crt_file(
|
||||
|
|
|
|||
64
src/main.zig
64
src/main.zig
|
|
@ -755,8 +755,8 @@ const SystemLib = struct {
|
|||
fn fallbackMode(this: SystemLib) std.builtin.LinkMode {
|
||||
assert(this.search_strategy != .no_fallback);
|
||||
return switch (this.preferred_mode) {
|
||||
.Dynamic => .Static,
|
||||
.Static => .Dynamic,
|
||||
.dynamic => .static,
|
||||
.static => .dynamic,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
@ -892,7 +892,7 @@ fn buildOutputType(
|
|||
var entitlements: ?[]const u8 = null;
|
||||
var pagezero_size: ?u64 = null;
|
||||
var lib_search_strategy: SystemLib.SearchStrategy = .paths_first;
|
||||
var lib_preferred_mode: std.builtin.LinkMode = .Dynamic;
|
||||
var lib_preferred_mode: std.builtin.LinkMode = .dynamic;
|
||||
var headerpad_size: ?u32 = null;
|
||||
var headerpad_max_install_names: bool = false;
|
||||
var dead_strip_dylibs: bool = false;
|
||||
|
|
@ -1166,22 +1166,22 @@ fn buildOutputType(
|
|||
};
|
||||
} else if (mem.eql(u8, arg, "-search_paths_first")) {
|
||||
lib_search_strategy = .paths_first;
|
||||
lib_preferred_mode = .Dynamic;
|
||||
lib_preferred_mode = .dynamic;
|
||||
} else if (mem.eql(u8, arg, "-search_paths_first_static")) {
|
||||
lib_search_strategy = .paths_first;
|
||||
lib_preferred_mode = .Static;
|
||||
lib_preferred_mode = .static;
|
||||
} else if (mem.eql(u8, arg, "-search_dylibs_first")) {
|
||||
lib_search_strategy = .mode_first;
|
||||
lib_preferred_mode = .Dynamic;
|
||||
lib_preferred_mode = .dynamic;
|
||||
} else if (mem.eql(u8, arg, "-search_static_first")) {
|
||||
lib_search_strategy = .mode_first;
|
||||
lib_preferred_mode = .Static;
|
||||
lib_preferred_mode = .static;
|
||||
} else if (mem.eql(u8, arg, "-search_dylibs_only")) {
|
||||
lib_search_strategy = .no_fallback;
|
||||
lib_preferred_mode = .Dynamic;
|
||||
lib_preferred_mode = .dynamic;
|
||||
} else if (mem.eql(u8, arg, "-search_static_only")) {
|
||||
lib_search_strategy = .no_fallback;
|
||||
lib_preferred_mode = .Static;
|
||||
lib_preferred_mode = .static;
|
||||
} else if (mem.eql(u8, arg, "-headerpad")) {
|
||||
const next_arg = args_iter.nextOrFatal();
|
||||
headerpad_size = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| {
|
||||
|
|
@ -1478,12 +1478,12 @@ fn buildOutputType(
|
|||
emit_implib = .no;
|
||||
emit_implib_arg_provided = true;
|
||||
} else if (mem.eql(u8, arg, "-dynamic")) {
|
||||
create_module.opts.link_mode = .Dynamic;
|
||||
lib_preferred_mode = .Dynamic;
|
||||
create_module.opts.link_mode = .dynamic;
|
||||
lib_preferred_mode = .dynamic;
|
||||
lib_search_strategy = .mode_first;
|
||||
} else if (mem.eql(u8, arg, "-static")) {
|
||||
create_module.opts.link_mode = .Static;
|
||||
lib_preferred_mode = .Static;
|
||||
create_module.opts.link_mode = .static;
|
||||
lib_preferred_mode = .static;
|
||||
lib_search_strategy = .no_fallback;
|
||||
} else if (mem.eql(u8, arg, "-fdll-export-fns")) {
|
||||
create_module.opts.dll_export_fns = true;
|
||||
|
|
@ -1904,7 +1904,7 @@ fn buildOutputType(
|
|||
},
|
||||
.nostdlib_cpp => create_module.opts.ensure_libcpp_on_non_freestanding = false,
|
||||
.shared => {
|
||||
create_module.opts.link_mode = .Dynamic;
|
||||
create_module.opts.link_mode = .dynamic;
|
||||
is_shared_lib = true;
|
||||
},
|
||||
.rdynamic => create_module.opts.rdynamic = true,
|
||||
|
|
@ -1961,20 +1961,20 @@ fn buildOutputType(
|
|||
mem.eql(u8, linker_arg, "-call_shared"))
|
||||
{
|
||||
lib_search_strategy = .no_fallback;
|
||||
lib_preferred_mode = .Dynamic;
|
||||
lib_preferred_mode = .dynamic;
|
||||
} else if (mem.eql(u8, linker_arg, "-Bstatic") or
|
||||
mem.eql(u8, linker_arg, "-dn") or
|
||||
mem.eql(u8, linker_arg, "-non_shared") or
|
||||
mem.eql(u8, linker_arg, "-static"))
|
||||
{
|
||||
lib_search_strategy = .no_fallback;
|
||||
lib_preferred_mode = .Static;
|
||||
lib_preferred_mode = .static;
|
||||
} else if (mem.eql(u8, linker_arg, "-search_paths_first")) {
|
||||
lib_search_strategy = .paths_first;
|
||||
lib_preferred_mode = .Dynamic;
|
||||
lib_preferred_mode = .dynamic;
|
||||
} else if (mem.eql(u8, linker_arg, "-search_dylibs_first")) {
|
||||
lib_search_strategy = .mode_first;
|
||||
lib_preferred_mode = .Dynamic;
|
||||
lib_preferred_mode = .dynamic;
|
||||
} else {
|
||||
try linker_args.append(linker_arg);
|
||||
}
|
||||
|
|
@ -3033,7 +3033,7 @@ fn buildOutputType(
|
|||
|
||||
const is_exe_or_dyn_lib = switch (create_module.resolved_options.output_mode) {
|
||||
.Obj => false,
|
||||
.Lib => create_module.resolved_options.link_mode == .Dynamic,
|
||||
.Lib => create_module.resolved_options.link_mode == .dynamic,
|
||||
.Exe => true,
|
||||
};
|
||||
// Note that cmake when targeting Windows will try to execute
|
||||
|
|
@ -3770,8 +3770,8 @@ fn createModule(
|
|||
)) {
|
||||
const path = try arena.dupe(u8, test_path.items);
|
||||
switch (info.preferred_mode) {
|
||||
.Static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.Dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.name = lib_name,
|
||||
.lib = .{
|
||||
.needed = info.needed,
|
||||
|
|
@ -3804,8 +3804,8 @@ fn createModule(
|
|||
)) {
|
||||
const path = try arena.dupe(u8, test_path.items);
|
||||
switch (info.fallbackMode()) {
|
||||
.Static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.Dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.name = lib_name,
|
||||
.lib = .{
|
||||
.needed = info.needed,
|
||||
|
|
@ -3838,8 +3838,8 @@ fn createModule(
|
|||
)) {
|
||||
const path = try arena.dupe(u8, test_path.items);
|
||||
switch (info.preferred_mode) {
|
||||
.Static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.Dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.name = lib_name,
|
||||
.lib = .{
|
||||
.needed = info.needed,
|
||||
|
|
@ -3862,8 +3862,8 @@ fn createModule(
|
|||
)) {
|
||||
const path = try arena.dupe(u8, test_path.items);
|
||||
switch (info.fallbackMode()) {
|
||||
.Static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.Dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.static => try create_module.link_objects.append(arena, .{ .path = path }),
|
||||
.dynamic => try create_module.resolved_system_libs.append(arena, .{
|
||||
.name = lib_name,
|
||||
.lib = .{
|
||||
.needed = info.needed,
|
||||
|
|
@ -6842,7 +6842,7 @@ fn accessLibPath(
|
|||
) !bool {
|
||||
const sep = fs.path.sep_str;
|
||||
|
||||
if (target.isDarwin() and link_mode == .Dynamic) tbd: {
|
||||
if (target.isDarwin() and link_mode == .dynamic) tbd: {
|
||||
// Prefer .tbd over .dylib.
|
||||
test_path.clearRetainingCapacity();
|
||||
try test_path.writer().print("{s}" ++ sep ++ "lib{s}.tbd", .{ lib_dir_path, lib_name });
|
||||
|
|
@ -6863,8 +6863,8 @@ fn accessLibPath(
|
|||
target.libPrefix(),
|
||||
lib_name,
|
||||
switch (link_mode) {
|
||||
.Static => target.staticLibSuffix(),
|
||||
.Dynamic => target.dynamicLibSuffix(),
|
||||
.static => target.staticLibSuffix(),
|
||||
.dynamic => target.dynamicLibSuffix(),
|
||||
},
|
||||
});
|
||||
try checked_paths.writer().print("\n {s}", .{test_path.items});
|
||||
|
|
@ -6879,7 +6879,7 @@ fn accessLibPath(
|
|||
|
||||
// In the case of Darwin, the main check will be .dylib, so here we
|
||||
// additionally check for .so files.
|
||||
if (target.isDarwin() and link_mode == .Dynamic) so: {
|
||||
if (target.isDarwin() and link_mode == .dynamic) so: {
|
||||
test_path.clearRetainingCapacity();
|
||||
try test_path.writer().print("{s}" ++ sep ++ "lib{s}.so", .{ lib_dir_path, lib_name });
|
||||
try checked_paths.writer().print("\n {s}", .{test_path.items});
|
||||
|
|
@ -6894,7 +6894,7 @@ fn accessLibPath(
|
|||
|
||||
// In the case of MinGW, the main check will be .lib but we also need to
|
||||
// look for `libfoo.a`.
|
||||
if (target.isMinGW() and link_mode == .Static) mingw: {
|
||||
if (target.isMinGW() and link_mode == .static) mingw: {
|
||||
test_path.clearRetainingCapacity();
|
||||
try test_path.writer().print("{s}" ++ sep ++ "lib{s}.a", .{
|
||||
lib_dir_path, lib_name,
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
|
|||
const strip = comp.compilerRtStrip();
|
||||
const config = try Compilation.Config.resolve(.{
|
||||
.output_mode = .Lib,
|
||||
.link_mode = .Dynamic,
|
||||
.link_mode = .dynamic,
|
||||
.resolved_target = comp.root_mod.resolved_target,
|
||||
.is_test = false,
|
||||
.have_zcu = false,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ test "exporting with internal linkage" {
|
|||
const S = struct {
|
||||
fn foo() callconv(.C) void {}
|
||||
comptime {
|
||||
@export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .Internal });
|
||||
@export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
|
||||
}
|
||||
};
|
||||
S.foo();
|
||||
|
|
@ -41,7 +41,7 @@ test "exporting using field access" {
|
|||
const x: u32 = 5;
|
||||
};
|
||||
comptime {
|
||||
@export(Inner.x, .{ .name = "foo", .linkage = .Internal });
|
||||
@export(Inner.x, .{ .name = "foo", .linkage = .internal });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ var internal_integer: usize = 1;
|
|||
var obj1_integer: usize = 421;
|
||||
|
||||
comptime {
|
||||
@export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal });
|
||||
@export(obj1_integer, .{ .name = "obj1_integer", .linkage = .Strong });
|
||||
@export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });
|
||||
@export(obj1_integer, .{ .name = "obj1_integer", .linkage = .strong });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ var internal_integer: usize = 2;
|
|||
var obj2_integer: usize = 422;
|
||||
|
||||
comptime {
|
||||
@export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal });
|
||||
@export(obj2_integer, .{ .name = "obj2_integer", .linkage = .Strong });
|
||||
@export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });
|
||||
@export(obj2_integer, .{ .name = "obj2_integer", .linkage = .strong });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
|
|||
} else if (mem.eql(u8, end_tag_name, "link_libc")) {
|
||||
link_libc = true;
|
||||
} else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) {
|
||||
link_mode = .Dynamic;
|
||||
link_mode = .dynamic;
|
||||
} else if (mem.eql(u8, end_tag_name, "additonal_option")) {
|
||||
_ = try eatToken(tokenizer, .separator);
|
||||
const option = try eatToken(tokenizer, .tag_content);
|
||||
|
|
@ -1793,11 +1793,11 @@ fn genHtml(
|
|||
}
|
||||
if (code.link_mode) |link_mode| {
|
||||
switch (link_mode) {
|
||||
.Static => {
|
||||
.static => {
|
||||
try test_args.append("-static");
|
||||
try shell_out.print("-static ", .{});
|
||||
},
|
||||
.Dynamic => {
|
||||
.dynamic => {
|
||||
try test_args.append("-dynamic");
|
||||
try shell_out.print("-dynamic ", .{});
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue