File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1334,12 +1334,17 @@ public final class ProductBuildDescription {
13341334 return [ " -Xlinker " , " -dead_strip " ]
13351335 } else if buildParameters. triple. isWindows ( ) {
13361336 return [ " -Xlinker " , " /OPT:REF " ]
1337- } else {
1338- // FIXME: wasm-ld / ld.lld strips data segments referenced through __start/__stop symbols
1337+ } else if buildParameters . triple . arch == . wasm32 {
1338+ // FIXME: wasm-ld strips data segments referenced through __start/__stop symbols
13391339 // during GC, and it removes Swift metadata sections like swift5_protocols
13401340 // We should add support of SHF_GNU_RETAIN-like flag for __attribute__((retain))
13411341 // to LLVM and wasm-ld
1342+ // This workaround is required for not only WASI but also all WebAssembly archs
1343+ // using wasm-ld (e.g. wasm32-unknown-unknown). So this branch is conditioned by
1344+ // arch == .wasm32
13421345 return [ ]
1346+ } else {
1347+ return [ " -Xlinker " , " --gc-sections " ]
13431348 }
13441349 }
13451350 }
Original file line number Diff line number Diff line change @@ -446,6 +446,7 @@ final class BuildPlanTests: XCTestCase {
446446 " -o " , buildPath. appending ( components: " exe " ) . pathString,
447447 " -module-name " , " exe " ,
448448 " -emit-executable " ,
449+ " -Xlinker " , " --gc-sections " ,
449450 " -Xlinker " , " -rpath=$ORIGIN " ,
450451 " @ \( buildPath. appending ( components: " exe.product " , " Objects.LinkFileList " ) ) " ,
451452 " -target " , defaultTargetTriple,
You can’t perform that action at this time.
0 commit comments