Skip to content

Commit 0ccd2b0

Browse files
committed
compiler: Always dynamically link executables for Fuchsia.
Fuchsia only supports PIE executables, specifically ET_DYN. https://fuchsia.dev/fuchsia-src/concepts/process/program_loading
1 parent a81fb5f commit 0ccd2b0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Compilation/Config.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub const ResolveError = error{
135135
LibCppRequiresLibC,
136136
LibUnwindRequiresLibC,
137137
TargetCannotDynamicLink,
138+
TargetCannotStaticLinkExecutables,
138139
LibCRequiresDynamicLinking,
139140
SharedLibrariesRequireDynamicLinking,
140141
ExportMemoryAndDynamicIncompatible,
@@ -360,6 +361,10 @@ pub fn resolve(options: Options) ResolveError!Config {
360361
if (options.link_mode == .dynamic) return error.TargetCannotDynamicLink;
361362
break :b .static;
362363
}
364+
if (target.os.tag == .fuchsia and options.output_mode == .Exe) {
365+
if (options.link_mode == .static) return error.TargetCannotStaticLinkExecutables;
366+
break :b .dynamic;
367+
}
363368
if (explicitly_exe_or_dyn_lib and link_libc and
364369
(target_util.osRequiresLibC(target) or
365370
// For these libcs, Zig can only provide dynamic libc when cross-compiling.

src/main.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4118,6 +4118,7 @@ fn createModule(
41184118
error.LibCppRequiresLibC => fatal("libc++ requires linking libc", .{}),
41194119
error.LibUnwindRequiresLibC => fatal("libunwind requires linking libc", .{}),
41204120
error.TargetCannotDynamicLink => fatal("dynamic linking unavailable on the specified target", .{}),
4121+
error.TargetCannotStaticLinkExecutables => fatal("static linking of executables unavailable on the specified target", .{}),
41214122
error.LibCRequiresDynamicLinking => fatal("libc of the specified target requires dynamic linking", .{}),
41224123
error.SharedLibrariesRequireDynamicLinking => fatal("using shared libraries requires dynamic linking", .{}),
41234124
error.ExportMemoryAndDynamicIncompatible => fatal("exporting memory is incompatible with dynamic linking", .{}),

0 commit comments

Comments
 (0)