Skip to content

Commit c9bca8a

Browse files
dianqkcuviper
authored andcommitted
Revert "[clang][WebAssembly] Support wasm32-wasi shared libraries"
This reverts commit a7d11c4. We just want to update the beta branch with the necessary fixes. This branch rustc/16.0-2023-06-05 has completed its mission on the master branch. So we can revert this commit for beta updates.
1 parent a19096d commit c9bca8a

File tree

4 files changed

+8
-36
lines changed

4 files changed

+8
-36
lines changed

clang/docs/ReleaseNotes.rst

-6
Original file line numberDiff line numberDiff line change
@@ -1103,12 +1103,6 @@ WebAssembly Support
11031103
^^^^^^^^^^^^^^^^^^^
11041104
- The -mcpu=generic configuration now enables sign-ext and mutable-globals. These
11051105
proposals are standardized and available in all major engines.
1106-
- Shared library support (and PIC code generation) for WebAssembly is no longer
1107-
limited to the Emscripten target OS and now works with other targets such as
1108-
wasm32-wasi. Note that the `format
1109-
<https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md>`_
1110-
is not yet stable and may change between LLVM versions. Also, WASI does not
1111-
yet have facilities to load dynamic libraries.
11121106

11131107
DWARF Support in Clang
11141108
----------------------

clang/lib/Driver/ToolChains/WebAssembly.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,13 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
101101
<< CM << A->getOption().getName();
102102
}
103103
}
104-
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, options::OPT_shared))
104+
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
105105
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
106106
if (Entry) {
107107
CmdArgs.push_back(Args.MakeArgString("--entry"));
108108
CmdArgs.push_back(Args.MakeArgString(Entry));
109109
}
110110

111-
if (Args.hasArg(options::OPT_shared))
112-
CmdArgs.push_back(Args.MakeArgString("-shared"));
113-
114111
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
115112

116113
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {

clang/test/Driver/wasm-toolchain.c

-26
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@
3333
// LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
3434
// LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
3535

36-
// -shared should be passed through to `wasm-ld` and not include crt1.o with a known OS.
37-
38-
// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
39-
// RUN: | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
40-
// LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
41-
// LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
42-
43-
// -shared should be passed through to `wasm-ld` and not include crt1.o with an unknown OS.
44-
45-
// RUN: %clang -### -shared --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
46-
// RUN: | FileCheck -check-prefix=LINK_UNKNOWN_SHARED %s
47-
// LINK_UNKNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
48-
// LINK_UNKNOWN_SHARED: wasm-ld{{.*}}" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
49-
5036
// A basic C link command-line with optimization with known OS.
5137

5238
// RUN: %clang -### -O2 --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
@@ -60,18 +46,6 @@
6046
// RUN: | FileCheck -check-prefix=COMPILE %s
6147
// COMPILE: "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
6248

63-
// -fPIC should work on a known OS
64-
65-
// RUN: %clang -### -fPIC --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
66-
// RUN: | FileCheck -check-prefix=COMPILE_KNOWN_PIC %s
67-
// COMPILE_KNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
68-
69-
// -fPIC should work on an unknown OS
70-
71-
// RUN: %clang -### -fPIC --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
72-
// RUN: | FileCheck -check-prefix=COMPILE_UNKNOWN_PIC %s
73-
// COMPILE_UNKNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2"
74-
7549
// Thread-related command line tests.
7650

7751
// '-pthread' sets +atomics, +bulk-memory, +mutable-globals, +sign-ext, and --shared-memory

llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM,
9898
return Reloc::Static;
9999
}
100100

101+
if (!TT.isOSEmscripten()) {
102+
// Relocation modes other than static are currently implemented in a way
103+
// that only works for Emscripten, so disable them if we aren't targeting
104+
// Emscripten.
105+
return Reloc::Static;
106+
}
107+
101108
return *RM;
102109
}
103110

0 commit comments

Comments
 (0)