r339163 - [WebAssembly] Remove use of lld -flavor flag

2018-08-07 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue Aug  7 11:55:41 2018
New Revision: 339163

URL: http://llvm.org/viewvc/llvm-project?rev=339163&view=rev
Log:
[WebAssembly] Remove use of lld -flavor flag

This flag is deprecated. The preferred way to select the lld
flavor is by calling it by one of its aliases.

Differential Revision: https://reviews.llvm.org/D50395

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Tue Aug  7 11:55:41 2018
@@ -41,8 +41,6 @@ void wasm::Linker::ConstructJob(Compilat
   const ToolChain &ToolChain = getToolChain();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("wasm");
 
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Tue Aug  7 11:55:41 2018
@@ -66,9 +66,7 @@ private:
llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
-  const char *getDefaultLinker() const override {
-return "lld";
-  }
+  const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
 };

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Tue Aug  7 11:55:41 2018
@@ -12,12 +12,12 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"

Modified: cfe/trunk/test/Driver/wasm-toolchain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.cpp?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.cpp (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.cpp Tue Aug  7 11:55:41 2018
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK 
%s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=wasm-ld %s 2>&1 | FileCheck 
-check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefi

[libcxxabi] r337982 - [CMake] Don't use LIBCXXABI_ENABLE_STATIC option before its declared

2018-07-25 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Wed Jul 25 16:13:00 2018
New Revision: 337982

URL: http://llvm.org/viewvc/llvm-project?rev=337982&view=rev
Log:
[CMake] Don't use LIBCXXABI_ENABLE_STATIC option before its declared

Summary:
rL337867 introduced two new cmake_dependent_option options:
- LIBCXXABI_INSTALL_STATIC_LIBRARY
- LIBCXXABI_INSTALL_SHARED_LIBRARY

They depend on LIBCXXABI_ENABLE_STATIC and LIBCXXABI_ENABLE_SHARED
and so therefore need to (it seems) come after the declaration of
these two options.

Subscribers: mgorny, aheejin, christof, ldionne, cfe-commits

Differential Revision: https://reviews.llvm.org/D49825

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=337982&r1=337981&r2=337982&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed Jul 25 16:13:00 2018
@@ -75,13 +75,6 @@ set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PAT
 set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
 
-cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY
-  "Install the static libc++abi library." ON
-  "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF)
-cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
-  "Install the shared libc++abi library." ON
-  "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF)
-
 # Default to building a shared library so that the default options still test
 # the libc++abi that is being built. There are two problems with testing a
 # static libc++abi. In the case of a standalone build, the tests will link the
@@ -91,6 +84,13 @@ cmake_dependent_option(LIBCXXABI_INSTALL
 option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
 option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
 
+cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY
+  "Install the static libc++abi library." ON
+  "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF)
+cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
+  "Install the shared libc++abi library." ON
+  "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF)
+
 cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY
   "Statically link the LLVM unwinder to static library" ON
   "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r306074 - [WebAssembly] Add default -allow-undefined-file to linker args

2017-06-23 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Jun 22 19:02:55 2017
New Revision: 306074

URL: http://llvm.org/viewvc/llvm-project?rev=306074&view=rev
Log:
[WebAssembly] Add default -allow-undefined-file to linker args

Also, don't use the outdated lib32/lib64 naming of files
within the sysroot. The more modern/flexible approach
IIUC is to use seperate sysroots or /lib/
and /include/.

Differential Revision: https://reviews.llvm.org/D33565

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=306074&r1=306073&r2=306074&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Thu Jun 22 19:02:55 2017
@@ -83,6 +83,8 @@ void wasm::Linker::ConstructJob(Compilat
 if (Args.hasArg(options::OPT_pthread))
   CmdArgs.push_back("-lpthread");
 
+CmdArgs.push_back("-allow-undefined-file");
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("wasm.syms")));
 CmdArgs.push_back("-lc");
 CmdArgs.push_back("-lcompiler_rt");
   }
@@ -104,8 +106,7 @@ WebAssembly::WebAssembly(const Driver &D
 
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-  getFilePaths().push_back(
-  getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
+  getFilePaths().push_back(getDriver().SysRoot + "/lib");
 }
 
 bool WebAssembly::IsMathErrnoDefault() const { return false; }

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=306074&r1=306073&r2=306074&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Jun 22 19:02:55 2017
@@ -27,18 +27,18 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib32" "crt1.o" "crti.o" 
"[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "crti.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // A basic C link command-line with optimization. WebAssembly is somewhat
 // special in enabling --gc-sections by default.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib" "crt1.o" 
"crti.o" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" 
"crtn.o" "-o" "a.out"
 
 // Ditto, but ensure that a user --no-gc-sections comes after the
 // default --gc-sections.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -Wl,--no-gc-sections %s 2>&1 | FileCheck 
-check-prefix=NO_GC_SECTIONS %s
 // NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" 
"-o" "a.out"
+// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-allow-undefined-file" 
"wasm.syms" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r320925 - [libcxx] Add WebAssembly support

2017-12-16 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Sat Dec 16 10:59:50 2017
New Revision: 320925

URL: http://llvm.org/viewvc/llvm-project?rev=320925&view=rev
Log:
[libcxx] Add WebAssembly support

It turns out that this is the only change required in libcxx
for it to compile with the new `wasm32-unknown-unknown-wasm`
target recently added to Clang.

Patch by Nicholas Wilson!

Differential Revision: https://reviews.llvm.org/D41073

Modified:
libcxx/trunk/include/__config
libcxx/trunk/src/include/config_elast.h

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=320925&r1=320924&r2=320925&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sat Dec 16 10:59:50 2017
@@ -45,6 +45,8 @@
 #define _LIBCPP_OBJECT_FORMAT_MACHO 1
 #elif defined(_WIN32)
 #define _LIBCPP_OBJECT_FORMAT_COFF  1
+#elif defined(__wasm__)
+#define _LIBCPP_OBJECT_FORMAT_WASM  1
 #else
 #error Unknown object file format
 #endif

Modified: libcxx/trunk/src/include/config_elast.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/config_elast.h?rev=320925&r1=320924&r2=320925&view=diff
==
--- libcxx/trunk/src/include/config_elast.h (original)
+++ libcxx/trunk/src/include/config_elast.h Sat Dec 16 10:59:50 2017
@@ -24,7 +24,7 @@
 #define _LIBCPP_ELAST __ELASTERROR
 #elif defined(__Fuchsia__)
 // No _LIBCPP_ELAST needed on Fuchsia
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 #define _LIBCPP_ELAST 4095
 #elif defined(__APPLE__)
 // No _LIBCPP_ELAST needed on Apple


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335380 - Fix BUILD_SHARED_LIBS=1 build of libclangHandleLLVM

2018-06-22 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Fri Jun 22 12:44:48 2018
New Revision: 335380

URL: http://llvm.org/viewvc/llvm-project?rev=335380&view=rev
Log:
Fix BUILD_SHARED_LIBS=1 build of libclangHandleLLVM

Differential Revision: https://reviews.llvm.org/D48503

Modified:
cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt?rev=335380&r1=335379&r2=335380&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt Fri Jun 22 12:44:48 
2018
@@ -1,4 +1,10 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
+set(LLVM_LINK_COMPONENTS
+  Core
+  IRReader
+  MC
+  Support
+  Analysis
+)
 
 add_clang_library(clangHandleLLVM
   handle_llvm.cpp


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r339163 - [WebAssembly] Remove use of lld -flavor flag

2018-10-17 Thread Sam Clegg via cfe-commits
The symlink is correct, the linker's name is just `wasm-ld`.   It is
also the default so you should be able to just drop the -fuse-ld
argument to make your command line work.  I looks like the real fix is
to update the handling of -fuse-ld.
On Tue, Oct 16, 2018 at 9:26 AM Nico Weber  wrote:
>
> $ bin/clang -target wasm32-unknown-unknown -fuse-ld=wasm-ld -o test.wasm 
> test.cc
> clang: error: invalid linker name in argument '-fuse-ld=wasm-ld'
>
> This here http://llvm-cs.pcc.me.uk/tools/clang/lib/Driver/ToolChain.cpp#453 
> makes clang look for "ld.wasm-ld", but the wasm lld symlink is called 
> "wasm-ld". Does the driver need updating? Is the symlink name wrong? Am I 
> doing something wrong?
>
> On Tue, Aug 7, 2018 at 2:56 PM Sam Clegg via cfe-commits 
>  wrote:
>>
>> Author: sbc
>> Date: Tue Aug  7 11:55:41 2018
>> New Revision: 339163
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=339163&view=rev
>> Log:
>> [WebAssembly] Remove use of lld -flavor flag
>>
>> This flag is deprecated. The preferred way to select the lld
>> flavor is by calling it by one of its aliases.
>>
>> Differential Revision: https://reviews.llvm.org/D50395
>>
>> Modified:
>> cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
>> cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
>> cfe/trunk/test/Driver/wasm-toolchain.c
>> cfe/trunk/test/Driver/wasm-toolchain.cpp
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=339163&r1=339162&r2=339163&view=diff
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Tue Aug  7 11:55:41 2018
>> @@ -41,8 +41,6 @@ void wasm::Linker::ConstructJob(Compilat
>>const ToolChain &ToolChain = getToolChain();
>>const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
>>ArgStringList CmdArgs;
>> -  CmdArgs.push_back("-flavor");
>> -  CmdArgs.push_back("wasm");
>>
>>if (Args.hasArg(options::OPT_s))
>>  CmdArgs.push_back("--strip-all");
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=339163&r1=339162&r2=339163&view=diff
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Tue Aug  7 11:55:41 2018
>> @@ -66,9 +66,7 @@ private:
>> llvm::opt::ArgStringList &CmdArgs) const 
>> override;
>>std::string getThreadModel() const override;
>>
>> -  const char *getDefaultLinker() const override {
>> -return "lld";
>> -  }
>> +  const char *getDefaultLinker() const override { return "wasm-ld"; }
>>
>>Tool *buildLinker() const override;
>>  };
>>
>> Modified: cfe/trunk/test/Driver/wasm-toolchain.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=339163&r1=339162&r2=339163&view=diff
>> ==
>> --- cfe/trunk/test/Driver/wasm-toolchain.c (original)
>> +++ cfe/trunk/test/Driver/wasm-toolchain.c Tue Aug  7 11:55:41 2018
>> @@ -12,12 +12,12 @@
>>
>>  // A basic C link command-line.
>>
>> -// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
>> --sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
>> +// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
>> --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
>>  // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
>> -// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
>> "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
>> +// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
>> "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
>>
>>  // A basic C link command-line with optimization.
>>
>

r356847 - [WebAssembly] Fix test/Driver/wasm-toolchain.c in the presence of CLANG_DEFAULT_LINKER

2019-03-23 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Sat Mar 23 17:03:41 2019
New Revision: 356847

URL: http://llvm.org/viewvc/llvm-project?rev=356847&view=rev
Log:
[WebAssembly] Fix test/Driver/wasm-toolchain.c in the presence of 
CLANG_DEFAULT_LINKER

This was broken in rL356817 (See https://reviews.llvm.org/D59721)

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=356847&r1=356846&r2=356847&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Sat Mar 23 17:03:41 2019
@@ -42,7 +42,7 @@
 // Thread-related command line tests.
 
 // '-pthread' sets '-target-feature +atomics' and '--shared-memory'
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s -pthread 2>&1 | FileCheck -check-prefix=PTHREAD %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 | FileCheck 
-check-prefix=PTHREAD %s
 // PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356953 - [WebAssembly] Don't use default GetLinkerPath

2019-03-25 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Mon Mar 25 14:14:26 2019
New Revision: 356953

URL: http://llvm.org/viewvc/llvm-project?rev=356953&view=rev
Log:
[WebAssembly] Don't use default GetLinkerPath

We can't (don't want to) honor the same set of "-fuse-ld" flags with
WebAssembly since the ELF linkers (ld.lld, ld.gnu, etc) don't work with
wasm object files.

Instead we implement our own linker finding logic, similar or other
non-ELF platforms like MSVC.

We've had a few issues with CLANG_DEFAULT_LINKER overriding the
WebAssembly linker which doesn't make sense since there is no generic
linker that can handle WebAssembly today.

Differential Revision: https://reviews.llvm.org/D59743

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=356953&r1=356952&r2=356953&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Mon Mar 25 14:14:26 2019
@@ -12,6 +12,8 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Option/ArgList.h"
 
 using namespace clang::driver;
@@ -36,6 +38,25 @@ bool wasm::Linker::isLinkJob() const { r
 
 bool wasm::Linker::hasIntegratedCPP() const { return false; }
 
+std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
+  const ToolChain &ToolChain = getToolChain();
+  if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
+StringRef UseLinker = A->getValue();
+if (!UseLinker.empty()) {
+  if (llvm::sys::path::is_absolute(UseLinker) &&
+  llvm::sys::fs::can_execute(UseLinker))
+return UseLinker;
+
+  // Accept 'lld', and 'ld' as aliases for the default linker
+  if (UseLinker != "lld" && UseLinker != "ld")
+ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
+<< A->getAsString(Args);
+}
+  }
+
+  return ToolChain.getDefaultLinker();
+}
+
 void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output,
 const InputInfoList &Inputs,
@@ -43,7 +64,7 @@ void wasm::Linker::ConstructJob(Compilat
 const char *LinkingOutput) const {
 
   const ToolChain &ToolChain = getToolChain();
-  const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
+  const char *Linker = Args.MakeArgString(getLinkerPath(Args));
   ArgStringList CmdArgs;
 
   if (Args.hasArg(options::OPT_s))

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=356953&r1=356952&r2=356953&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Mon Mar 25 14:14:26 2019
@@ -23,6 +23,7 @@ public:
   explicit Linker(const ToolChain &TC);
   bool isLinkJob() const override;
   bool hasIntegratedCPP() const override;
+  std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=356953&r1=356952&r2=356953&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Mar 25 14:14:26 2019
@@ -12,25 +12,25 @@
 
 // A basic C link command-line with unknown OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with unknown OS.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %

r357195 - [WebAssembly] Reland of rL356953 (4dcf3acce6)

2019-03-28 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Mar 28 10:45:18 2019
New Revision: 357195

URL: http://llvm.org/viewvc/llvm-project?rev=357195&view=rev
Log:
[WebAssembly] Reland of rL356953 (4dcf3acce6)

The previous patch was missing GetProgramPath() in the return value
of getLinkerPath().

See https://reviews.llvm.org/D59743

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=357195&r1=357194&r2=357195&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Thu Mar 28 10:45:18 2019
@@ -12,6 +12,8 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Option/ArgList.h"
 
 using namespace clang::driver;
@@ -36,6 +38,25 @@ bool wasm::Linker::isLinkJob() const { r
 
 bool wasm::Linker::hasIntegratedCPP() const { return false; }
 
+std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
+  const ToolChain &ToolChain = getToolChain();
+  if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
+StringRef UseLinker = A->getValue();
+if (!UseLinker.empty()) {
+  if (llvm::sys::path::is_absolute(UseLinker) &&
+  llvm::sys::fs::can_execute(UseLinker))
+return UseLinker;
+
+  // Accept 'lld', and 'ld' as aliases for the default linker
+  if (UseLinker != "lld" && UseLinker != "ld")
+ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
+<< A->getAsString(Args);
+}
+  }
+
+  return ToolChain.GetProgramPath(ToolChain.getDefaultLinker());
+}
+
 void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output,
 const InputInfoList &Inputs,
@@ -43,7 +64,7 @@ void wasm::Linker::ConstructJob(Compilat
 const char *LinkingOutput) const {
 
   const ToolChain &ToolChain = getToolChain();
-  const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
+  const char *Linker = Args.MakeArgString(getLinkerPath(Args));
   ArgStringList CmdArgs;
 
   if (Args.hasArg(options::OPT_s))

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=357195&r1=357194&r2=357195&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Thu Mar 28 10:45:18 2019
@@ -23,6 +23,7 @@ public:
   explicit Linker(const ToolChain &TC);
   bool isLinkJob() const override;
   bool hasIntegratedCPP() const override;
+  std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=357195&r1=357194&r2=357195&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Mar 28 10:45:18 2019
@@ -12,25 +12,25 @@
 
 // A basic C link command-line with unknown OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with unknown OS.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with known OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl 
--sysroot=/foo -fuse-

r313307 - [WebAssembly] Fix wasm-toolchain.c tests

2017-09-14 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Sep 14 15:36:44 2017
New Revision: 313307

URL: http://llvm.org/viewvc/llvm-project?rev=313307&view=rev
Log:
[WebAssembly] Fix wasm-toolchain.c tests

Summary: This test should have been updated in r313299

Subscribers: jfb, dschuff, jgravelle-google, aheejin

Differential Revision: https://reviews.llvm.org/D37873

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=313307&r1=313306&r2=313307&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Sep 14 15:36:44 2017
@@ -27,18 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "crti.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"
 
-// A basic C link command-line with optimization. WebAssembly is somewhat
-// special in enabling --gc-sections by default.
+// A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib" "crt1.o" 
"crti.o" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" 
"crtn.o" "-o" "a.out"
-
-// Ditto, but ensure that a user --no-gc-sections comes after the
-// default --gc-sections.
-
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -Wl,--no-gc-sections %s 2>&1 | FileCheck 
-check-prefix=NO_GC_SECTIONS %s
-// NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-allow-undefined-file" 
"wasm.syms" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313299 - [WebAssembly] Remove invliad lld arguments

2017-09-14 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Sep 14 14:29:25 2017
New Revision: 313299

URL: http://llvm.org/viewvc/llvm-project?rev=313299&view=rev
Log:
[WebAssembly] Remove invliad lld arguments

These arguments don't (not yet at least) make sense for
the wasm lld port.

Subscribers: jfb, dschuff, jgravelle-google, aheejin

Differential Revision: https://reviews.llvm.org/D36595

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=313299&r1=313298&r2=313299&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Thu Sep 14 14:29:25 2017
@@ -43,36 +43,12 @@ void wasm::Linker::ConstructJob(Compilat
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("wasm");
 
-  // Enable garbage collection of unused input sections by default, since code
-  // size is of particular importance. This is significantly facilitated by
-  // the enabling of -ffunction-sections and -fdata-sections in
-  // Clang::ConstructJob.
-  if (areOptimizationsEnabled(Args))
-CmdArgs.push_back("--gc-sections");
-
-  if (Args.hasArg(options::OPT_rdynamic))
-CmdArgs.push_back("-export-dynamic");
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");
-  if (Args.hasArg(options::OPT_shared))
-CmdArgs.push_back("-shared");
-  if (Args.hasArg(options::OPT_static))
-CmdArgs.push_back("-Bstatic");
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-if (Args.hasArg(options::OPT_shared))
-  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("rcrt1.o")));
-else if (Args.hasArg(options::OPT_pie))
-  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("Scrt1.o")));
-else
-  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
-
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
-  }
-
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -88,9 +64,6 @@ void wasm::Linker::ConstructJob(Compilat
 CmdArgs.push_back("-lcompiler_rt");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362180 - Fix -DBUILD_SHARED_LIBS=ON build after rL362160

2019-05-30 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu May 30 18:04:00 2019
New Revision: 362180

URL: http://llvm.org/viewvc/llvm-project?rev=362180&view=rev
Log:
Fix -DBUILD_SHARED_LIBS=ON build after rL362160

Differential Revision: https://reviews.llvm.org/D62709

Modified:
cfe/trunk/lib/CodeGen/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=362180&r1=362179&r2=362180&view=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Thu May 30 18:04:00 2019
@@ -17,6 +17,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Passes
   ProfileData
+  Remarks
   ScalarOpts
   Support
   Target


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362959 - [WebAssembly] Cleanup toolchain test files. NFC.

2019-06-10 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Mon Jun 10 09:18:04 2019
New Revision: 362959

URL: http://llvm.org/viewvc/llvm-project?rev=362959&view=rev
Log:
[WebAssembly] Cleanup toolchain test files. NFC.

Summary: Split up long lines to improve test readability.

Subscribers: dschuff, jgravelle-google, aheejin, sunfish, jfb, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63081

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=362959&r1=362958&r2=362959&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Jun 10 09:18:04 2019
@@ -1,51 +1,62 @@
 // A basic clang -cc1 command-line. WebAssembly is somewhat special in
 // enabling -fvisibility=hidden by default.
 
-// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}}
 
 // Ditto, but ensure that a user -fvisibility=default disables the default
 // -fvisibility=hidden.
 
-// RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 
2>&1 | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
+// RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 
2>&1 \
+// RUN:   | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
 // FVISIBILITY_DEFAULT-NOT: hidden
 
 // A basic C link command-line with unknown OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with unknown OS.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with known OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo 
%s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo 
%s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN %s
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with known OS.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-wasi 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT_KNOWN %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-wasi 
--sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_KNOWN %s
 // LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C compile command-line with known OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo 
%s 2>&1 | FileCheck -check-prefix=COMPILE %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo 
%s 2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE %s
 // COMPILE: clang{{.*}}" "-cc1" {{.*}} "-internal-isystem" 
"/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
 
 // Thread-related command line tests.
 
 // '-pthread' sets '-target-feature +atomics' and '--shared-memory'
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 | FileCheck 
-check-prefix=PTHREAD %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
+// RUN:  | FileCheck -check-prefix=PTHREAD %s
 // PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
-// RU

r363238 - [clang-scan-deps] Fix -DBUILD_SHARED_LIBS=ON build

2019-06-13 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Jun 13 01:58:46 2019
New Revision: 363238

URL: http://llvm.org/viewvc/llvm-project?rev=363238&view=rev
Log:
[clang-scan-deps] Fix -DBUILD_SHARED_LIBS=ON build

The -DBUILD_SHARED_LIBS=ON build was broken in rL363204

Differential Revision: https://reviews.llvm.org/D63245

Modified:
cfe/trunk/tools/clang-scan-deps/CMakeLists.txt

Modified: cfe/trunk/tools/clang-scan-deps/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-scan-deps/CMakeLists.txt?rev=363238&r1=363237&r2=363238&view=diff
==
--- cfe/trunk/tools/clang-scan-deps/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-scan-deps/CMakeLists.txt Thu Jun 13 01:58:46 2019
@@ -16,6 +16,7 @@ set(CLANG_SCAN_DEPS_LIB_DEPS
   clangFrontendTool
   clangLex
   clangParse
+  clangSerialization
   clangTooling
   )
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363241 - [WebAssembly] Modernize include path handling

2019-06-13 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Jun 13 02:42:43 2019
New Revision: 363241

URL: http://llvm.org/viewvc/llvm-project?rev=363241&view=rev
Log:
[WebAssembly] Modernize include path handling

Move include path construction from
InitHeaderSearch::AddDefaultIncludePaths in the Driver which appears
to be the more modern/correct way of doing things.

Differential Revision: https://reviews.llvm.org/D63030

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=363241&r1=363240&r2=363241&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Thu Jun 13 02:42:43 2019
@@ -8,6 +8,7 @@
 
 #include "WebAssembly.h"
 #include "CommonArgs.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -170,14 +171,39 @@ WebAssembly::GetCXXStdlibType(const ArgL
 
 void WebAssembly::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
 ArgStringList &CC1Args) const {
-  if (!DriverArgs.hasArg(options::OPT_nostdinc)) {
-if (getTriple().getOS() != llvm::Triple::UnknownOS) {
-  const std::string MultiarchTriple =
-  getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
-  addSystemInclude(DriverArgs, CC1Args, getDriver().SysRoot + "/include/" 
+ MultiarchTriple);
+  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
+return;
+
+  const Driver &D = getDriver();
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> P(D.ResourceDir);
+llvm::sys::path::append(P, "include");
+addSystemInclude(DriverArgs, CC1Args, P);
+  }
+
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Check for configure-time C include directories.
+  StringRef CIncludeDirs(C_INCLUDE_DIRS);
+  if (CIncludeDirs != "") {
+SmallVector dirs;
+CIncludeDirs.split(dirs, ":");
+for (StringRef dir : dirs) {
+  StringRef Prefix =
+  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
-addSystemInclude(DriverArgs, CC1Args, getDriver().SysRoot + "/include");
+return;
+  }
+
+  if (getTriple().getOS() != llvm::Triple::UnknownOS) {
+const std::string MultiarchTriple =
+getMultiarchTriple(D, getTriple(), D.SysRoot);
+addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include/" + 
MultiarchTriple);
   }
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
 }
 
 void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
@@ -188,7 +214,8 @@ void WebAssembly::AddClangCXXStdlibInclu
   const std::string MultiarchTriple =
   getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
   addSystemInclude(DriverArgs, CC1Args,
-   getDriver().SysRoot + "/include/" + MultiarchTriple + 
"/c++/v1");
+   getDriver().SysRoot + "/include/" + MultiarchTriple +
+   "/c++/v1");
 }
 addSystemInclude(DriverArgs, CC1Args,
  getDriver().SysRoot + "/include/c++/v1");

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=363241&r1=363240&r2=363241&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Jun 13 02:42:43 2019
@@ -414,9 +414,11 @@ void InitHeaderSearch::AddDefaultInclude
   default:
 break; // Everything else continues to use this routine's logic.
 
+  case llvm::Triple::Emscripten:
   case llvm::Triple::Linux:
   case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
+  case llvm::Triple::WASI:
 return;
 
   case llvm::Triple::Win32:
@@ -424,6 +426,12 @@ void InitHeaderSearch::AddDefaultInclude
 triple.isOSBinFormatMachO())
   return;
 break;
+
+  case llvm::Triple::UnknownOS:
+if (triple.getArch() == llvm::Triple::wasm32 ||
+triple.getArch() == llvm::Triple::wasm64)
+  return;
+break;
   }
 
   // All header search logic is handled in the Driver for Darwin.

Modified: cfe/trunk/test/Driver/wasm-toolchain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.cpp?rev=363241&r1=363240&r2=363241&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.cpp (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.cpp Thu Jun 13 0

r363759 - git-clang-format: Remove trailing whitespace in docstring. NFC.

2019-06-18 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue Jun 18 18:52:41 2019
New Revision: 363759

URL: http://llvm.org/viewvc/llvm-project?rev=363759&view=rev
Log:
git-clang-format: Remove trailing whitespace in docstring. NFC.

Differential Revision: https://reviews.llvm.org/D62915

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=363759&r1=363758&r2=363759&view=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Tue Jun 18 18:52:41 2019
@@ -8,19 +8,19 @@
 #
 
#======#
 
-r"""   
  
-clang-format git integration   
  
-   
  
-   
  
-This file provides a clang-format integration for git. Put it somewhere in 
your  
-path and ensure that it is executable. Then, "git clang-format" will invoke
  
-clang-format on the changes in current files or a specific commit. 
  
-   
  
-For further details, run:  
  
-git clang-format -h
  
-   
  
-Requires Python 2.7 or Python 3
  
-"""   
+r"""
+clang-format git integration
+
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
 
 from __future__ import absolute_import, division, print_function
 import argparse


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366518 - Fix formatting of inline argument comments. NFC.

2019-07-18 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Jul 18 17:30:23 2019
New Revision: 366518

URL: http://llvm.org/viewvc/llvm-project?rev=366518&view=rev
Log:
Fix formatting of inline argument comments. NFC.

Also, remove the final arg from ItaniumCXXABI in the PNaCl case since
its not needed.

Differential Revision: https://reviews.llvm.org/D64955

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=366518&r1=366517&r2=366518&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Jul 18 17:30:23 2019
@@ -415,8 +415,8 @@ public:
 class ARMCXXABI : public ItaniumCXXABI {
 public:
   ARMCXXABI(CodeGen::CodeGenModule &CGM) :
-ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true,
-  /* UseARMGuardVarABI = */ true) {}
+ItaniumCXXABI(CGM, /*UseARMMethodPtrABI=*/true,
+  /*UseARMGuardVarABI=*/true) {}
 
   bool HasThisReturn(GlobalDecl GD) const override {
 return (isa(GD.getDecl()) || (
@@ -480,11 +480,11 @@ CodeGen::CGCXXABI *CodeGen::CreateItaniu
   // include the other 32-bit ARM oddities: constructor/destructor return 
values
   // and array cookies.
   case TargetCXXABI::GenericAArch64:
-return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true,
- /* UseARMGuardVarABI = */ true);
+return new ItaniumCXXABI(CGM, /*UseARMMethodPtrABI=*/true,
+ /*UseARMGuardVarABI=*/true);
 
   case TargetCXXABI::GenericMIPS:
-return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true);
+return new ItaniumCXXABI(CGM, /*UseARMMethodPtrABI=*/true);
 
   case TargetCXXABI::WebAssembly:
 return new WebAssemblyCXXABI(CGM);
@@ -495,8 +495,7 @@ CodeGen::CGCXXABI *CodeGen::CreateItaniu
   // For PNaCl, use ARM-style method pointers so that PNaCl code
   // does not assume anything about the alignment of function
   // pointers.
-  return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true,
-   /* UseARMGuardVarABI = */ false);
+  return new ItaniumCXXABI(CGM, /*UseARMMethodPtrABI=*/true);
 }
 return new ItaniumCXXABI(CGM);
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361651 - [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Fri May 24 10:36:07 2019
New Revision: 361651

URL: http://llvm.org/viewvc/llvm-project?rev=361651&view=rev
Log:
[WebAssembly] Use "linker" as linker shortname.

This is in line with other platforms.

Also, move the single statement methods into the header (also
in line with other platform).

Differential Revision: https://reviews.llvm.org/D62406

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=361651&r1=361650&r2=361651&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Fri May 24 10:36:07 2019
@@ -22,9 +22,6 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain &TC)
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver &D,
@@ -34,10 +31,6 @@ static std::string getMultiarchTriple(co
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
   const ToolChain &ToolChain = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=361651&r1=361650&r2=361651&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Fri May 24 10:36:07 2019
@@ -20,9 +20,10 @@ namespace wasm {
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain &TC);
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain &TC)
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335510 - [WebAssembly] Add no-prototype attribute to prototype-less C functions

2018-06-25 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Mon Jun 25 11:47:32 2018
New Revision: 335510

URL: http://llvm.org/viewvc/llvm-project?rev=335510&view=rev
Log:
[WebAssembly] Add no-prototype attribute to prototype-less C functions

The WebAssembly backend in particular benefits from being
able to distinguish between varargs functions (...) and prototype-less
C functions.

Differential Revision: https://reviews.llvm.org/D48443

Added:
cfe/trunk/test/CodeGen/no-prototype.c   (with props)
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=335510&r1=335509&r2=335510&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Jun 25 11:47:32 2018
@@ -747,6 +747,15 @@ class WebAssemblyTargetCodeGenInfo final
 public:
   explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
   : TargetCodeGenInfo(new WebAssemblyABIInfo(CGT)) {}
+
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule &CGM) const override {
+if (auto *FD = dyn_cast_or_null(D)) {
+  llvm::Function *Fn = cast(GV);
+  if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype())
+Fn->addFnAttr("no-prototype");
+}
+  }
 };
 
 /// Classify argument of given type \p Ty.

Added: cfe/trunk/test/CodeGen/no-prototype.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/no-prototype.c?rev=335510&view=auto
==
--- cfe/trunk/test/CodeGen/no-prototype.c (added)
+++ cfe/trunk/test/CodeGen/no-prototype.c Mon Jun 25 11:47:32 2018
@@ -0,0 +1,20 @@
+// REQUIRES: webassembly-registered-target
+// RUN: %clang_cc1 -triple wasm32 -emit-llvm %s -o - | FileCheck %s
+
+int foo();
+
+int bar(int a) {
+  return foo();
+}
+
+int baz() {
+  return foo();
+}
+
+// CHECK: define i32 @bar(i32 %a) [[BAR_ATTR:#[0-9]+]] {
+// CHECK: declare i32 @foo(...) [[FOO_ATTR:#[0-9]+]]
+// CHECK: define i32 @baz() [[BAZ_ATTR:#[0-9]+]] {
+
+// CHECK: attributes [[FOO_ATTR]] = {  {{.*}}"no-prototype"{{.*}} }
+// CHECK-NOT: attributes [[BAR_ATTR]] = {  {{.*}}"no-prototype"{{.*}} }
+// CHECK-NOT: attributes [[BAZ_ATTR]] = {  {{.*}}"no-prototype"{{.*}} }

Propchange: cfe/trunk/test/CodeGen/no-prototype.c
--
svn:eol-style = LF


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5804a8b - [WebAssebmly] Fully disable 'protected' visibility

2020-06-23 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2020-06-23T17:50:05-07:00
New Revision: 5804a8b1228ba890d48f4085a3a192ef83c73e00

URL: 
https://github.com/llvm/llvm-project/commit/5804a8b1228ba890d48f4085a3a192ef83c73e00
DIFF: 
https://github.com/llvm/llvm-project/commit/5804a8b1228ba890d48f4085a3a192ef83c73e00.diff

LOG: [WebAssebmly] Fully disable 'protected' visibility

Emscripten doesn't use protected visibility either.

Differential Revision: https://reviews.llvm.org/D82346

Added: 


Modified: 
clang/lib/Basic/Targets/WebAssembly.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index e09e21d90802..77a2fe9ae117 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -133,11 +133,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : 
public TargetInfo {
 
   bool hasExtIntType() const override { return true; }
 
-  bool hasProtectedVisibility() const override {
-// TODO: For now, continue to advertise "protected" support for
-// Emscripten targets.
-return getTriple().isOSEmscripten();
-  }
+  bool hasProtectedVisibility() const override { return false; }
 };
 
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319623 - [WebAssembly] Pass through --undefined to Wasm LLD

2017-12-02 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Sat Dec  2 15:11:13 2017
New Revision: 319623

URL: http://llvm.org/viewvc/llvm-project?rev=319623&view=rev
Log:
[WebAssembly] Pass through --undefined to Wasm LLD

This is a follow-on to D40724 (Wasm entrypoint changes #1,
add `--undefined` argument to LLD).

Patch by Nicholas Wilson

Differential Revision: https://reviews.llvm.org/D40739

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=319623&r1=319622&r2=319623&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Sat Dec  2 15:11:13 2017
@@ -47,6 +47,7 @@ void wasm::Linker::ConstructJob(Compilat
 CmdArgs.push_back("--strip-all");
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 849df8f - [clang][WebAssembly] Pass `-Wa,--no-type-check` through to the MC layer

2022-09-01 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2022-09-01T02:56:58-07:00
New Revision: 849df8f6f0a6ded83e36aa52b6daa6b950289804

URL: 
https://github.com/llvm/llvm-project/commit/849df8f6f0a6ded83e36aa52b6daa6b950289804
DIFF: 
https://github.com/llvm/llvm-project/commit/849df8f6f0a6ded83e36aa52b6daa6b950289804.diff

LOG: [clang][WebAssembly] Pass `-Wa,--no-type-check` through to the MC layer

I took as an example the `-Wa,--noexecstack` clang flag that maps down
to `cc1 -mnoexecstack`.

Differential Revision: https://reviews.llvm.org/D131217

Added: 
clang/test/Driver/notypecheck.s

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/driver/cc1as_main.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 87c75bb98d433..55c6940fb34c1 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -180,6 +180,7 @@ CODEGENOPT(NoExecStack   , 1, 0) ///< Set when 
-Wa,--noexecstack is enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
 CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled.
+CODEGENOPT(NoTypeCheck   , 1, 0) ///< Set when -Wa,--no-type-check is 
enabled.
 CODEGENOPT(MisExpect , 1, 0) ///< Set when -Wmisexpect is enabled
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
 CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2aef6d5d95720..ee1012efc086d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5286,6 +5286,9 @@ def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
"Note this may change .s semantics and shouldn't generally be used "
"on compiler-generated code.">,
   MarshallingInfoFlag>;
+def mno_type_check : Flag<["-"], "mno-type-check">,
+  HelpText<"Don't perform type checking of the assembly code (wasm only)">,
+  MarshallingInfoFlag>;
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1fa83e7121c95..eb7ad39d7edc7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2580,6 +2580,13 @@ static void 
CollectArgsForIntegratedAssembler(Compilation &C,
   switch (C.getDefaultToolChain().getArch()) {
   default:
 break;
+  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm64:
+if (Value == "--no-type-check") {
+  CmdArgs.push_back("-mno-type-check");
+  continue;
+}
+break;
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
   case llvm::Triple::arm:

diff  --git a/clang/test/Driver/notypecheck.s b/clang/test/Driver/notypecheck.s
new file mode 100644
index 0..f6e78d6791182
--- /dev/null
+++ b/clang/test/Driver/notypecheck.s
@@ -0,0 +1,13 @@
+# REQUIRES: webassembly-registered-target
+
+# RUN: %clang -### %s -c -o tmp.o -target wasm32-unknown-unknown 
-Wa,--no-type-check 2>&1 | FileCheck %s
+# CHECK: "-cc1as" {{.*}} "-mno-type-check"
+
+# Verify that without -Wa,--no-type-check the assembler will error out
+# RUN: not %clang %s -c -o tmp.o -target wasm32-unknown-unknown 2>&1 | 
FileCheck --check-prefix=ERROR %s
+# ERROR: error: popped i64, expected i32
+
+foo:
+  .functype  foo () -> (i32)
+  i64.const 42
+  end_function

diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 5498810d835cd..5e528a00aa778 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -134,6 +134,7 @@ struct AssemblerInvocation {
   unsigned NoExecStack : 1;
   unsigned FatalWarnings : 1;
   unsigned NoWarn : 1;
+  unsigned NoTypeCheck : 1;
   unsigned IncrementalLinkerCompatible : 1;
   unsigned EmbedBitcode : 1;
 
@@ -166,6 +167,7 @@ struct AssemblerInvocation {
 NoExecStack = 0;
 FatalWarnings = 0;
 NoWarn = 0;
+NoTypeCheck = 0;
 IncrementalLinkerCompatible = 0;
 Dwarf64 = 0;
 DwarfVersion = 0;
@@ -304,6 +306,7 @@ bool 
AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
   Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
   Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
+  Opts.NoTypeCheck = Args.hasArg(OPT_mno_type_check);
   Opts.RelocationModel =
   std::string(Args.getLastArgValue(OPT_mrelocation_model, "pic"));
   Opts.TargetABI = std::string(

[clang] 89d5635 - [lld][WebAssembly] Add --keep-section flag

2023-11-02 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2023-11-02T14:23:45-07:00
New Revision: 89d5635f0a834e53ac5446c6d6ea38d9166b2a55

URL: 
https://github.com/llvm/llvm-project/commit/89d5635f0a834e53ac5446c6d6ea38d9166b2a55
DIFF: 
https://github.com/llvm/llvm-project/commit/89d5635f0a834e53ac5446c6d6ea38d9166b2a55.diff

LOG: [lld][WebAssembly] Add --keep-section flag

This flag causes wasm-ld preserve a section even in the face of
`--strip-all`.  This is useful, for example, to preserve the
target_features section in the ase of clang (which can run wasm-opt
after linking), and emcc (which performs a bunch of post-link work).

Fixes: https://github.com/llvm/llvm-project/issues/60613
Fixes: https://github.com/llvm/llvm-project/issues/55781

Differential Revision: https://reviews.llvm.org/D149917

Added: 
lld/test/wasm/strip-all.s

Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
lld/wasm/Config.h
lld/wasm/Driver.cpp
lld/wasm/Options.td
lld/wasm/SyntheticSections.h

Removed: 
lld/test/wasm/strip-all.test



diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index fe0b30b7250b824..f04018179a5dab7 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,14 +141,25 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  // When optimizing, if wasm-opt is available, run it.
+  std::string WasmOptPath;
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
+if (WasmOptPath == "wasm-opt") {
+  WasmOptPath = {};
+}
+  }
+
+  if (!WasmOptPath.empty()) {
+CmdArgs.push_back("--keep-section=target_features");
+  }
+
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
  Linker, CmdArgs, Inputs, Output));
 
-  // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-auto WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
-if (WasmOptPath != "wasm-opt") {
+if (!WasmOptPath.empty()) {
   StringRef OOpt = "s";
   if (A->getOption().matches(options::OPT_O4) ||
   A->getOption().matches(options::OPT_Ofast))
@@ -160,13 +171,13 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (OOpt != "0") {
 const char *WasmOpt = Args.MakeArgString(WasmOptPath);
-ArgStringList CmdArgs;
-CmdArgs.push_back(Output.getFilename());
-CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
-CmdArgs.push_back("-o");
-CmdArgs.push_back(Output.getFilename());
+ArgStringList OptArgs;
+OptArgs.push_back(Output.getFilename());
+OptArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+OptArgs.push_back("-o");
+OptArgs.push_back(Output.getFilename());
 C.addCommand(std::make_unique(
-JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, CmdArgs,
+JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, OptArgs,
 Inputs, Output));
   }
 }

diff  --git a/lld/test/wasm/strip-all.s b/lld/test/wasm/strip-all.s
new file mode 100644
index 000..b0819a29f8028a4
--- /dev/null
+++ b/lld/test/wasm/strip-all.s
@@ -0,0 +1,36 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.start.o
+# RUN: wasm-ld --strip-all -o %t.wasm %t.start.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+#
+## Test alias -s
+# RUN: wasm-ld -s -o %t2.wasm %t.start.o
+# RUN: obj2yaml %t2.wasm | FileCheck %s
+#
+## Check that there is no name section
+# CHECK-NOT:   Name:name
+# CHECK-NOT:   Name:target_features
+#
+## Test --keep-section=name preserver the name section
+# RUN: wasm-ld --strip-all --keep-section=name -o %t3.wasm %t.start.o
+# RUN: obj2yaml %t3.wasm | FileCheck --check-prefix=CHECK-NAME %s
+#
+# CHECK-NAME:   Name:name
+# CHECK-NAME-NOT:   Name:target_features
+#
+## Test --keep-section can be specified more than once
+# RUN: wasm-ld --strip-all --keep-section=name --keep-section=target_features 
-o %t4.wasm %t.start.o
+# RUN: obj2yaml %t4.wasm | FileCheck --check-prefix=CHECK-FEATURES %s
+#
+# CHECK-FEATURES:   Name:name
+# CHECK-FEATURES:   Name:target_features
+
+  .globl  _start
+_start:
+  .functype _start () -> ()
+  end_function
+
+.section .custom_section.target_features,"",@
+.int8 1
+.int8 43
+.int8 15
+.ascii "mutable-globals"

diff  --git a/lld/test/wasm/strip-all.test b/lld/test/wasm/strip-all.test
deleted file mode 100644
index ae3314f30676c50..000
--- a/lld/test/wasm/strip-all.test
+++ /dev/null
@@ -1,10 +0,0 @@
-RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unk

[clang] ecbcefd - [clang][WebAssemmbly] Call TargetInfo::adjust in derived method.

2022-02-10 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2022-02-10T16:04:06-08:00
New Revision: ecbcefd693dd62f9242618b3cf838565e829cc7f

URL: 
https://github.com/llvm/llvm-project/commit/ecbcefd693dd62f9242618b3cf838565e829cc7f
DIFF: 
https://github.com/llvm/llvm-project/commit/ecbcefd693dd62f9242618b3cf838565e829cc7f.diff

LOG: [clang][WebAssemmbly] Call TargetInfo::adjust in derived method.

The superclass method handles a bunch of useful things. For example
it applies flags such as `-fnew-alignment` which doesn't work without
this patch.

Differential Revision: https://reviews.llvm.org/D118573

Added: 


Modified: 
clang/lib/Basic/Targets/WebAssembly.cpp
clang/test/CXX/cpp/cpp.predefined/p1.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 2309997eb77b2..023c03c7cf5c0 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -255,6 +255,7 @@ ArrayRef 
WebAssemblyTargetInfo::getTargetBuiltins() const {
 
 void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags,
LangOptions &Opts) {
+  TargetInfo::adjust(Diags, Opts);
   // If the Atomics feature isn't available, turn off POSIXThreads and
   // ThreadModel, so that we don't predefine _REENTRANT or __STDCPP_THREADS__.
   if (!HasAtomics) {

diff  --git a/clang/test/CXX/cpp/cpp.predefined/p1.cpp 
b/clang/test/CXX/cpp/cpp.predefined/p1.cpp
index c0dcbd54f3873..42a80d37c43d1 100644
--- a/clang/test/CXX/cpp/cpp.predefined/p1.cpp
+++ b/clang/test/CXX/cpp/cpp.predefined/p1.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++1z %s -verify -triple x86_64-linux-gnu -DALIGN=16
 // RUN: %clang_cc1 -std=c++1z %s -verify -fnew-alignment=2 -DALIGN=2
 // RUN: %clang_cc1 -std=c++1z %s -verify -fnew-alignment=256 -DALIGN=256
+// RUN: %clang_cc1 -std=c++1z %s -verify -triple wasm32-unknown-unknown 
-fnew-alignment=256 -DALIGN=256
 
 // expected-no-diagnostics
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-13 Thread Sam Clegg via cfe-commits


@@ -198,9 +198,18 @@
 ///
 /// If there are calls to setjmp()
 ///
-/// 2) and 3): The same as 2) and 3) in Emscripten SjLj.
-/// (setjmpTable/setjmpTableSize initialization + setjmp callsite
-/// transformation)
+/// 2) In the function entry that calls setjmp, initialize
+///functionInvocationId as follows:
+///
+///functionInvocationId = alloca()

sbc100 wrote:

Can you include the size that passed to alloca here?  

 (looks like its getInt32Ty() so maybe put 4 here?)

https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-13 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 edited https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-13 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 commented:

Let me know if you want some help testing alsongside the emscripten side.

Alternatively myself or @aheejin could perform the emscripten tests.

https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-13 Thread Sam Clegg via cfe-commits


@@ -198,9 +198,18 @@
 ///
 /// If there are calls to setjmp()
 ///
-/// 2) and 3): The same as 2) and 3) in Emscripten SjLj.
-/// (setjmpTable/setjmpTableSize initialization + setjmp callsite
-/// transformation)
+/// 2) In the function entry that calls setjmp, initialize
+///functionInvocationId as follows:
+///
+///functionInvocationId = alloca()

sbc100 wrote:

Is the same functionInvocationId used even if there are several calls to setjmp 
inside the same function?  

https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Change the default linker for `wasm32-wasip2` (PR #84569)

2024-03-18 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 approved this pull request.


https://github.com/llvm/llvm-project/pull/84569
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-25 Thread Sam Clegg via cfe-commits

sbc100 wrote:

Is this good to land now?  @yamt do you have commit access or should @aheejin 
or myself land this?

https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Add more features to generic CPU config (PR #80923)

2024-02-06 Thread Sam Clegg via cfe-commits

sbc100 wrote:

@kripken 

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Add more features to generic CPU config (PR #80923)

2024-02-06 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> Tried running Emscripten tests, and some of them fail with reference-types or 
> bulk-memory. I haven't investigated the causes yet, but it could be better to 
> start with the other two (nontrapping-fptoint and multivalue).

No need to block these on emscripten failures.. I'm sure we can find and fix 
those.   We should make this decision based on current browser stats and 
release dates I think,

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-07 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 commented:

Thanks for working on this!

I'm excited to see this land and become less emscripten-specific. 

I'm hoping that once we get the emscripten side landed we can remove the new 
option very soon too.


https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-07 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 edited https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-07 Thread Sam Clegg via cfe-commits


@@ -999,25 +1002,42 @@ bool 
WebAssemblyLowerEmscriptenEHSjLj::runOnModule(Module &M) {
   // Register __wasm_longjmp function, which calls __builtin_wasm_longjmp.
   FunctionType *FTy = FunctionType::get(
   IRB.getVoidTy(), {Int8PtrTy, IRB.getInt32Ty()}, false);
-  WasmLongjmpF = getEmscriptenFunction(FTy, "__wasm_longjmp", &M);
+  if (EnableWasmAltSjLj) {
+WasmLongjmpF = getEmscriptenFunction(FTy, "__wasm_sjlj_longjmp", &M);
+  } else {
+WasmLongjmpF = getEmscriptenFunction(FTy, "__wasm_longjmp", &M);
+  }
   WasmLongjmpF->addFnAttr(Attribute::NoReturn);
 }
 
 if (SetjmpF) {
   Type *Int8PtrTy = IRB.getPtrTy();
   Type *Int32PtrTy = IRB.getPtrTy();
   Type *Int32Ty = IRB.getInt32Ty();
-  // Register saveSetjmp function
-  FunctionType *SetjmpFTy = SetjmpF->getFunctionType();
-  FunctionType *FTy = FunctionType::get(
-  Int32PtrTy,
-  {SetjmpFTy->getParamType(0), Int32Ty, Int32PtrTy, Int32Ty}, false);
-  SaveSetjmpF = getEmscriptenFunction(FTy, "saveSetjmp", &M);
 
   // Register testSetjmp function

sbc100 wrote:

This comment should probably be moved to line 1027 and line 1037?

https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-08 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 commented:

In terms of getting this landed and tested, I wonder which path we should take:

1.  Land this now, without tests, then update emscripten then come back and 
flip the default, at which point the existing tests will get updated.
2. Duplicate/update the the existing tests to tests both modes, then delete 
those changes once we flip the default.

Personally I think I'd be happy with (1) since this is a behind and 
experimental flag.

What do others think?  @aheejin ?


https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Change the default linker for `wasm32-wasip2` (PR #84569)

2024-03-08 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 commented:

Does wasm-component-ld accept any other input types other than the ones that 
wasm-ld accepts?

Does wasm-component-ld call wasm-ld internally?

Do we expect clang users to be building compound components using a single 
clang command?  i.e. will they be somehow supplying input files that describe 
how the componend links?   Would it make more sense to have clang default to 
building core modules and have the component creation be a higher level thing 
built on top clang outputs?

https://github.com/llvm/llvm-project/pull/84569
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Change the default linker for `wasm32-wasip2` (PR #84569)

2024-03-08 Thread Sam Clegg via cfe-commits

sbc100 wrote:

Regarding WebAssembly/wasi-sdk and WebAssembly/wasi-libc, is there any reason 
why simple programs wouldn't be core modules?   Won't most C/C++ programs still 
be build-able as just core modules?  

https://github.com/llvm/llvm-project/pull/84569
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Change the default linker for `wasm32-wasip2` (PR #84569)

2024-03-08 Thread Sam Clegg via cfe-commits

sbc100 wrote:

I see, so `wasm-ld` builds "core module + metadata" and then 
`wasm-component-ld` takes that metadata and uses it to wrap the core module 
into a component (with exactly that one core module inside of it). 

So the core module + metadata is kind of isomorphic with that 
single-core-module-component?





https://github.com/llvm/llvm-project/pull/84569
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Change the default linker for `wasm32-wasip2` (PR #84569)

2024-03-08 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> Currently it accepts no extra inputs, but in the future I'd expect that it'll 
> grow an option or two of its own

I was more asking about whether the file types is accepts are anything more 
than object files and libraries.  i.e. can you pass other core modules and have 
wasm-component-ld build a component that contains more than one core module?

Also, can you say more about the metadata that is being using to drive 
wasm-componenet-ld?If the core module is all based on canonical ABI what 
extra metdata is needed/planned?

https://github.com/llvm/llvm-project/pull/84569
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-09 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> > In terms of getting this landed and tested, I wonder which path we should 
> > take:
> > 
> > 1. Land this now, without tests, then update emscripten then come back and 
> > flip the default, at which point the existing tests will get updated.
> > 2. Duplicate/update the the existing tests to tests both modes, then delete 
> > those changes once we flip the default.
> > 
> > Personally I think I'd be happy with (1) since this is a behind and 
> > experimental flag.
> > What do others think? @aheejin ?
> 
> Come to think of it, should we even introduce this experimental option? 
> Adding `if (NewOption) ... else ...` everywhere makes the code complicated. 
> Can we just do
> 
> 1. Add library functions in emscripten

So you think it should be possible to have both old and new versions supported 
in emscripten at the same time?If that works that would be great.  Do you 
want to send and emscripten PR?  And link to it here?   If we can confirm that 
all tests pass then I agree it would be great to do this in a single LLVM 
change.

> 2. Replace the current logic in LLVM with new code. (Without `if`~`else`). 
> Tests can be updated with this.
> 3. Remove old library functions in emscripten.
>?



https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

2024-03-11 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> @aheejin @sbc100 let me confirm the plan on this PR. i can remove the option 
> `-mllvm -experimental-wasm-enable-alt-sjlj` by making it unconditionally 
> true, and update tests, right?

That is my understanding yes.

https://github.com/llvm/llvm-project/pull/84137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang-tools-extra] [lld] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)

2024-01-24 Thread Sam Clegg via cfe-commits


@@ -259,10 +259,13 @@ class InputFunction : public InputChunk {
 file->codeSection->Content.slice(inputSectionOffset, function->Size);
 debugName = function->DebugName;
 comdat = function->Comdat;
+assert(s.Kind != WasmSignature::Placeholder);

sbc100 wrote:

Should we give a more useful error message here? 

Perhaps we simply not set `isRelocatableObject()` for any object file that 
contains any of these.  Then the linker would simply error on them before 
getting this far?

https://github.com/llvm/llvm-project/pull/79235
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] Embed the command line arguments during LTO (PR #79390)

2024-01-24 Thread Sam Clegg via cfe-commits


@@ -40,6 +41,7 @@ using namespace llvm;
 namespace lld::wasm {
 static std::unique_ptr createLTO() {
   lto::Config c;
+  c.EmbedCmdArgs = commonContext().cmdArgs;

sbc100 wrote:

It looks like `commonContext()` is not actually used elsewhere in lld, and this 
should probably just be `context()`?

https://github.com/llvm/llvm-project/pull/79390
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [lld] [clang] Embed the command line arguments during LTO (PR #79390)

2024-01-24 Thread Sam Clegg via cfe-commits


@@ -40,6 +41,7 @@ using namespace llvm;
 namespace lld::wasm {
 static std::unique_ptr createLTO() {
   lto::Config c;
+  c.EmbedCmdArgs = commonContext().cmdArgs;

sbc100 wrote:

How about adding a helper like the existing ones `CommonLinkerContext.h`:

```
inline llvm::StringSaver &saver() { return context().saver; }
```

This means that the current linker code just calls `saver()` whenever it needs 
it.


https://github.com/llvm/llvm-project/pull/79390
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [lld] [clang] Embed the command line arguments during LTO (PR #79390)

2024-01-24 Thread Sam Clegg via cfe-commits


@@ -40,6 +41,7 @@ using namespace llvm;
 namespace lld::wasm {
 static std::unique_ptr createLTO() {
   lto::Config c;
+  c.EmbedCmdArgs = commonContext().cmdArgs;

sbc100 wrote:

(I'm not sure why `context()` needs to take a template param, and it looks like 
its optional.. none of the current uses seem to specify one).

https://github.com/llvm/llvm-project/pull/79390
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] Embed the command line arguments during LTO (PR #79390)

2024-01-24 Thread Sam Clegg via cfe-commits


@@ -40,6 +41,7 @@ using namespace llvm;
 namespace lld::wasm {
 static std::unique_ptr createLTO() {
   lto::Config c;
+  c.EmbedCmdArgs = commonContext().cmdArgs;

sbc100 wrote:

I think it might be the other way around.  It looks like only COFF currently 
supported specialized contexts.  The one I work on (Wasm) currently doesn't, 
for example.

https://github.com/llvm/llvm-project/pull/79390
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] [clang-tools-extra] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)

2024-01-24 Thread Sam Clegg via cfe-commits


@@ -259,10 +259,13 @@ class InputFunction : public InputChunk {
 file->codeSection->Content.slice(inputSectionOffset, function->Size);
 debugName = function->DebugName;
 comdat = function->Comdat;
+assert(s.Kind != WasmSignature::Placeholder);

sbc100 wrote:

Yes, perhaps another flag in the object file, ("hasGCTypes").. or perhaps the 
linker to iterate through the types section to make sure it understands them 
all and error out if it doesn't?

https://github.com/llvm/llvm-project/pull/79235
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [clang] [lld] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)

2024-01-24 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 approved this pull request.


https://github.com/llvm/llvm-project/pull/79235
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 04febd3 - [lld][WebAssembly] Error on import/export of mutable global without `mutable-globals` feature

2020-09-12 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2020-09-12T14:28:14-07:00
New Revision: 04febd30a8dab3ff4b6e6032f1a1a9f4725f8267

URL: 
https://github.com/llvm/llvm-project/commit/04febd30a8dab3ff4b6e6032f1a1a9f4725f8267
DIFF: 
https://github.com/llvm/llvm-project/commit/04febd30a8dab3ff4b6e6032f1a1a9f4725f8267.diff

LOG: [lld][WebAssembly] Error on import/export of mutable global without 
`mutable-globals` feature

Also add the +mutable-globals features in clang when
building with `-fPIC` since the linker will generate mutable
globals imports and exports in that case.

Differential Revision: https://reviews.llvm.org/D87537

Added: 
lld/test/wasm/mutable-globals.s

Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c
lld/test/wasm/Inputs/undefined-globals.s
lld/test/wasm/emit-relocs-fpic.s
lld/test/wasm/gc-imports.s
lld/test/wasm/pie.ll
lld/test/wasm/shared.ll
lld/wasm/Writer.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 10168736400f..d953082470aa 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -243,6 +243,27 @@ void WebAssembly::addClangTargetOptions(const ArgList 
&DriverArgs,
 CC1Args.push_back("+sign-ext");
   }
 
+  if (!DriverArgs.hasFlag(options::OPT_mmutable_globals,
+  options::OPT_mno_mutable_globals, false)) {
+// -fPIC implies +mutable-globals because the PIC ABI used by the linker
+// depends on importing and exporting mutable globals.
+llvm::Reloc::Model RelocationModel;
+unsigned PICLevel;
+bool IsPIE;
+std::tie(RelocationModel, PICLevel, IsPIE) =
+ParsePICArgs(*this, DriverArgs);
+if (RelocationModel == llvm::Reloc::PIC_) {
+  if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+ options::OPT_mmutable_globals, false)) {
+getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+<< "-fPIC"
+<< "-mno-mutable-globals";
+  }
+  CC1Args.push_back("-target-feature");
+  CC1Args.push_back("+mutable-globals");
+}
+  }
+
   if (DriverArgs.getLastArg(options::OPT_fwasm_exceptions)) {
 // '-fwasm-exceptions' is not compatible with '-mno-exception-handling'
 if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,

diff  --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index ad8b000ad225..3c2eb66f9e19 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -119,3 +119,14 @@
 // RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
 // CHECK-REACTOR: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // CHECK-REACTOR: wasm-ld{{.*}}" "crt1-reactor.o" "--entry" "_initialize" 
"[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
+// -fPIC implies +mutable-globals
+
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIC %s
+// CHECK-PIC: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+mutable-globals"
+
+// '-mno-mutable-globals' is not allowed with '-fPIC'
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
+// PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with 
'-mno-mutable-globals'

diff  --git a/lld/test/wasm/Inputs/undefined-globals.s 
b/lld/test/wasm/Inputs/undefined-globals.s
index 607d7942d003..54dc4189a777 100644
--- a/lld/test/wasm/Inputs/undefined-globals.s
+++ b/lld/test/wasm/Inputs/undefined-globals.s
@@ -7,5 +7,5 @@ use_undef_global:
   global.get used_undef_global
   end_function
 
-.globaltype unused_undef_global, i64
-.globaltype used_undef_global, i64
+.globaltype unused_undef_global, i64, immutable
+.globaltype used_undef_global, i64, immutable

diff  --git a/lld/test/wasm/emit-relocs-fpic.s 
b/lld/test/wasm/emit-relocs-fpic.s
index c70e1e675109..1d81ca62786b 100644
--- a/lld/test/wasm/emit-relocs-fpic.s
+++ b/lld/test/wasm/emit-relocs-fpic.s
@@ -1,6 +1,6 @@
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o < %s
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s 
-o %t.ret32.o
-# RUN: wasm-ld -pie --export-all --no-gc-sections --no-entry --emit-relocs -o 
%t.wasm %t.o %t.ret32.o
+# RUN: wasm-ld -pie --export-all --no-check-features --no-gc-sections 
--no-entry --emit-relocs -o %t.wasm %t.o %t.ret32.o
 # RUN: obj2yaml %t.wasm | FileCheck %s
 
 load_hidden_data:

diff  --git a/lld/test/wasm/gc-imports.s b/lld/test/wasm/gc-imports.s
index 6564b5c1a7d8..1f8bca9064e0 100644

[clang] 38a2858 - [clang][emscripten] Add builtin define for __EMSCRIPTEN_PTHREADS__

2021-02-05 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2021-02-05T13:53:05-08:00
New Revision: 38a285885dd5f3634d7824da2a6aefe5e39782a7

URL: 
https://github.com/llvm/llvm-project/commit/38a285885dd5f3634d7824da2a6aefe5e39782a7
DIFF: 
https://github.com/llvm/llvm-project/commit/38a285885dd5f3634d7824da2a6aefe5e39782a7.diff

LOG: [clang][emscripten] Add builtin define for __EMSCRIPTEN_PTHREADS__

Currently the emscripten frontend driver injects this when building
with thread support.  Moving this into the clang driver itself makes
the emscripten python driver less magical.

Differential Revision: https://reviews.llvm.org/D96171

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 67fa1a537fea..2d6303aa55dc 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -940,6 +940,8 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
 MacroBuilder &Builder) const final {
 WebAssemblyOSTargetInfo::getOSDefines(Opts, Triple, Builder);
 Builder.defineMacro("__EMSCRIPTEN__");
+if (Opts.POSIXThreads)
+  Builder.defineMacro("__EMSCRIPTEN_PTHREADS__");
   }
 
 public:

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index e29b6d3972f8..136200a97840 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1473,6 +1473,15 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm64-unknown-unknown \
 // RUN:   < /dev/null \
 // RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-emscripten \
+// RUN:   < /dev/null \
+// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,EMSCRIPTEN %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-emscripten -pthread -target-feature +atomics \
+// RUN:   < /dev/null \
+// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,EMSCRIPTEN,EMSCRIPTEN-THREADS %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm64-emscripten \
+// RUN:   < /dev/null \
+// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,EMSCRIPTEN %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-wasi \
 // RUN:   < /dev/null \
 // RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-WASI %s
@@ -1490,6 +1499,7 @@
 // WEBASSEMBLY32-NOT:#define _LP64
 // WEBASSEMBLY64-NOT:#define _ILP32
 // WEBASSEMBLY64:#define _LP64 1
+// EMSCRIPTEN-THREADS:#define _REENTRANT 1
 // WEBASSEMBLY-NEXT:#define __ATOMIC_ACQUIRE 2
 // WEBASSEMBLY-NEXT:#define __ATOMIC_ACQ_REL 4
 // WEBASSEMBLY-NEXT:#define __ATOMIC_CONSUME 1
@@ -1529,6 +1539,8 @@
 // WEBASSEMBLY-NEXT:#define __DBL_MIN__ 2.2250738585072014e-308
 // WEBASSEMBLY-NEXT:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
 // WEBASSEMBLY-NOT:#define __ELF__
+// EMSCRIPTEN-THREADS-NEXT:#define __EMSCRIPTEN_PTHREADS__ 1
+// EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1
 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
 // WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d1a96e9 - [clang][emscripten] Reduce alignof long double from 16 to 8 bytes

2021-07-02 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2021-07-02T11:05:40-07:00
New Revision: d1a96e906cc03a95cfd41a1f22bdda92651250c7

URL: 
https://github.com/llvm/llvm-project/commit/d1a96e906cc03a95cfd41a1f22bdda92651250c7
DIFF: 
https://github.com/llvm/llvm-project/commit/d1a96e906cc03a95cfd41a1f22bdda92651250c7.diff

LOG: [clang][emscripten] Reduce alignof long double from 16 to 8 bytes

This means `max_align_t` is 8 bytes which also sets the alignment
malloc.  Since this is technically and ABI breaking change we have
limited to just the emscripten OS target.  It is also relatively low
import breakage since it will only effect the alignement of struct that
contai `long double`s (extremerly rare I imagine).

Emscripten's malloc implementation already use 8 byte alignement
(dlmalloc uses and alignement of 2*sizeof(void*) == 8 rather than
checking max_align_t) so will not be effected by this change.  By
bringing the ABI in line with the current malloc code this will fix
several issue we have seen in the wild.

See: https://github.com/emscripten-core/emscripten/pull/14456

Differential Revision: https://reviews.llvm.org/D104808

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index ce56b4f1f005e..335ca5635642c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -948,8 +948,16 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
   }
 
 public:
-  explicit EmscriptenTargetInfo(const llvm::Triple &Triple, const 
TargetOptions &Opts)
-  : WebAssemblyOSTargetInfo(Triple, Opts) {}
+  explicit EmscriptenTargetInfo(const llvm::Triple &Triple,
+const TargetOptions &Opts)
+  : WebAssemblyOSTargetInfo(Triple, Opts) {
+// Keeping the alignment of long double to 8 bytes even though its size is
+// 16 bytes allows emscripten to have an 8-byte-aligned max_align_t which
+// in turn gives is a 8-byte aligned malloc.
+// Emscripten's ABI is unstable and we may change this back to 128 to match
+// the WebAssembly default in the future.
+this->LongDoubleAlign = 64;
+  }
 };
 
 } // namespace targets



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 78747bd - [clang][WebAssembly] Loosen restriction on `main` symbol mangling

2022-06-15 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2022-06-15T13:56:05-07:00
New Revision: 78747bd39af807eb6b56709b9713c303704c47ad

URL: 
https://github.com/llvm/llvm-project/commit/78747bd39af807eb6b56709b9713c303704c47ad
DIFF: 
https://github.com/llvm/llvm-project/commit/78747bd39af807eb6b56709b9713c303704c47ad.diff

LOG: [clang][WebAssembly] Loosen restriction on `main` symbol mangling

Remove the `hasPrototype()` restriction so that old style K&R
declarations of main work too.

For example the following has 2 params but no prototype.

```
int main(argc, argv)
int argc;
char *argv[];
{
  return 0;
}
```

Also, use `getNumParams()` over `param_size()` which seems to be a more
direct way to get at the same information.

Also, add missing tests for this mangling.

Differential Revision: https://reviews.llvm.org/D127888

Added: 
clang/test/CodeGen/mangle-wasm-main-noproto.c
clang/test/CodeGen/mangle-wasm-main-void.c
clang/test/CodeGen/mangle-wasm-main.c

Modified: 
clang/lib/AST/Mangle.cpp

Removed: 




diff  --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index c1a345390091b..7ea569c63d9e4 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@ static CCMangling getCallingConvMangling(const ASTContext 
&Context,
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())

diff  --git a/clang/test/CodeGen/mangle-wasm-main-noproto.c 
b/clang/test/CodeGen/mangle-wasm-main-noproto.c
new file mode 100644
index 0..313ce36216e25
--- /dev/null
+++ b/clang/test/CodeGen/mangle-wasm-main-noproto.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown 
-Wno-deprecated-non-prototype | FileCheck %s
+
+int main(argc, argv)
+  int argc;
+  char* argv[];
+{
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 

diff  --git a/clang/test/CodeGen/mangle-wasm-main-void.c 
b/clang/test/CodeGen/mangle-wasm-main-void.c
new file mode 100644
index 0..f541e555ff728
--- /dev/null
+++ b/clang/test/CodeGen/mangle-wasm-main-void.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(void) {
+  return 0;
+}
+// CHECK: @__main_void = hidden alias i32 (), ptr @main
+// CHECK: define i32 @main() #0 {

diff  --git a/clang/test/CodeGen/mangle-wasm-main.c 
b/clang/test/CodeGen/mangle-wasm-main.c
new file mode 100644
index 0..3a16d068666fa
--- /dev/null
+++ b/clang/test/CodeGen/mangle-wasm-main.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(int argc, char* argv[]) {
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 47039a1 - [WebAssembly] Remove restriction on main name mangling

2022-06-06 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2022-06-06T14:04:27-07:00
New Revision: 47039a1a4b299c01dfa0ec531fbc0d24718bb8eb

URL: 
https://github.com/llvm/llvm-project/commit/47039a1a4b299c01dfa0ec531fbc0d24718bb8eb
DIFF: 
https://github.com/llvm/llvm-project/commit/47039a1a4b299c01dfa0ec531fbc0d24718bb8eb.diff

LOG: [WebAssembly] Remove restriction on main name mangling

Summary: Emscripten now handles/supports this new mode.

Subscribers: dschuff, jgravelle-google, aheejin, sunfish, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75277

Added: 


Modified: 
clang/lib/AST/Mangle.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 984da9909ce23..c1a345390091b 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -70,9 +70,7 @@ static CCMangling getCallingConvMangling(const ASTContext 
&Context,
 
   // On wasm, the argc/argv form of "main" is renamed so that the startup code
   // can call it with the correct function signature.
-  // On Emscripten, users may be exporting "main" and expecting to call it
-  // themselves, so we can't mangle it.
-  if (Triple.isWasm() && !Triple.isOSEmscripten())
+  if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
   if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
 return CCM_WasmMainArgcArgv;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index afb28c1e5cc97..c3507fad0d79d 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -554,10 +554,8 @@ void CodeGenModule::Release() {
 CodeGenFunction(*this).EmitCfiCheckStub();
   }
   emitAtAvailableLinkGuard();
-  if (Context.getTargetInfo().getTriple().isWasm() &&
-  !Context.getTargetInfo().getTriple().isOSEmscripten()) {
+  if (Context.getTargetInfo().getTriple().isWasm())
 EmitMainVoidAlias();
-  }
 
   if (getTriple().isAMDGPU()) {
 // Emit reference of __amdgpu_device_library_preserve_asan_functions to
@@ -6352,8 +6350,10 @@ void CodeGenModule::EmitMainVoidAlias() {
   // new-style no-argument main is in used.
   if (llvm::Function *F = getModule().getFunction("main")) {
 if (!F->isDeclaration() && F->arg_size() == 0 && !F->isVarArg() &&
-F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth()))
-  addUsedGlobal(llvm::GlobalAlias::create("__main_void", F));
+
F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth())) {
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(llvm::GlobalValue::HiddenVisibility);
+}
   }
 }
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Update generic CPU configuration to include nontrapping-fptoint (PR #67459)

2023-09-26 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 created 
https://github.com/llvm/llvm-project/pull/67459

Enable nontrapping-fptoint in -mcpu=generic. This makes this feature enabled by 
default.

This feature is part of [finished proposals], and all major wasm engines 
support it.

[finished proposals]: 
https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md

>From e69ea7277c3ddf73c5f14fdcb9927e3e12f95c2a Mon Sep 17 00:00:00 2001
From: Sam Clegg 
Date: Tue, 26 Sep 2023 09:55:59 -0700
Subject: [PATCH] [WebAssembly] Update generic CPU configuration to include
 nontrapping-fptoint

Enable nontrapping-fptoint in -mcpu=generic. This makes this feature
enabled by default.

This feature is part of [finished proposals], and all major wasm engines
support it.

[finished proposals]: 
https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md
---
 clang/docs/ReleaseNotes.rst   | 2 ++
 clang/lib/Basic/Targets/WebAssembly.cpp   | 1 +
 llvm/lib/Target/WebAssembly/WebAssembly.td| 3 ++-
 llvm/test/CodeGen/WebAssembly/fpclamptosat.ll | 2 +-
 llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll | 2 +-
 llvm/test/MC/WebAssembly/basic-assembly-errors.s  | 2 +-
 llvm/test/MC/WebAssembly/basic-assembly.s | 4 ++--
 llvm/test/MC/WebAssembly/data-section.s   | 8 
 llvm/test/MC/WebAssembly/objdump.s| 2 +-
 llvm/test/MC/WebAssembly/type-index.s | 4 ++--
 llvm/test/MC/WebAssembly/wasm64.s | 4 ++--
 11 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8a136aae5489a8c..28c035a3fdf2db1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -453,6 +453,8 @@ AIX Support
 
 WebAssembly Support
 ^^^
+The -mcpu=generic configuration now enables -nontrapping-fptoint. This
+proposals are standardized and available in all major engines.
 
 AVR Support
 ^^^
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index f1c925d90cb649f..791c8c29fc6bcad 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -158,6 +158,7 @@ bool WebAssemblyTargetInfo::initFeatureMap(
 Features["multimemory"] = true;
 setSIMDLevel(Features, SIMD128, true);
   } else if (CPU == "generic") {
+Features["nontrapping-fptoint"] = true;
 Features["sign-ext"] = true;
 Features["mutable-globals"] = true;
   }
diff --git a/llvm/lib/Target/WebAssembly/WebAssembly.td 
b/llvm/lib/Target/WebAssembly/WebAssembly.td
index d538197450b65b0..efae460b6faa9bf 100644
--- a/llvm/lib/Target/WebAssembly/WebAssembly.td
+++ b/llvm/lib/Target/WebAssembly/WebAssembly.td
@@ -107,7 +107,8 @@ def : ProcessorModel<"mvp", NoSchedModel, []>;
 // consideration given to available support in relevant engines and tools, and
 // the importance of the features.
 def : ProcessorModel<"generic", NoSchedModel,
-  [FeatureSignExt, FeatureMutableGlobals]>;
+  [FeatureNontrappingFPToInt, FeatureSignExt,
+   FeatureMutableGlobals]>;
 
 // Latest and greatest experimental version of WebAssembly. Bugs included!
 def : ProcessorModel<"bleeding-edge", NoSchedModel,
diff --git a/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll 
b/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
index 58e3f0dc2a93c0b..78cc9c1f8e6da90 100644
--- a/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
+++ b/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=wasm32-unknown-unknown 
-mattr=+simd128,+nontrapping-fptoint | FileCheck %s
+; RUN: llc < %s -mtriple=wasm32-unknown-unknown -mattr=+simd128 | FileCheck %s
 
 ; i32 saturate
 
diff --git a/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll 
b/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
index 8f85575c1cf4312..d3321e771f13946 100644
--- a/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
+++ b/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=wasm32-unknown-unknown 
-mattr=+simd128,+nontrapping-fptoint | FileCheck %s
+; RUN: llc < %s -mtriple=wasm32-unknown-unknown -mattr=+simd128 | FileCheck %s
 
 ; i32 saturate
 
diff --git a/llvm/test/MC/WebAssembly/basic-assembly-errors.s 
b/llvm/test/MC/WebAssembly/basic-assembly-errors.s
index aab3b5b1a9028e0..cd063b69b4840d9 100644
--- a/llvm/test/MC/WebAssembly/basic-assembly-errors.s
+++ b/llvm/test/MC/WebAssembly/basic-assembly-errors.s
@@ -1,4 +1,4 @@
-# RUN: not llvm-mc -triple=wasm32-unknown-unknown 
-mattr=+simd128,+nontrapping-fptoint,+exception-handling %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -triple=wasm32-unknown-unknown 
-mattr=+simd128,+exception-handling %s 2>&1 | FileCheck %s
 
 # CHECK: invalid operand f

[clang] [WebAssembly] Update generic CPU configuration to include nontrapping-fptoint (PR #67459)

2023-09-26 Thread Sam Clegg via cfe-commits

sbc100 wrote:

@kripken @dschuff @sunfishcode, can you remember why we didn't include this is 
part of https://reviews.llvm.org/D125728 and https://reviews.llvm.org/D125729?  
 Has the landscape changed enough since then that we can/should land this now?

https://github.com/llvm/llvm-project/pull/67459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Update generic CPU configuration to include nontrapping-fptoint (PR #67459)

2023-09-26 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 updated 
https://github.com/llvm/llvm-project/pull/67459

>From 64d9d8eb1da9f275cde47bd92c39e600e5a2f9b3 Mon Sep 17 00:00:00 2001
From: Sam Clegg 
Date: Tue, 26 Sep 2023 09:55:59 -0700
Subject: [PATCH] [WebAssembly] Update generic CPU configuration to include
 nontrapping-fptoint

Enable nontrapping-fptoint in -mcpu=generic. This makes this feature
enabled by default.

This feature is part of [finished proposals], and all major wasm engines
support it.

[finished proposals]: 
https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md
---
 clang/docs/ReleaseNotes.rst   | 2 ++
 clang/lib/Basic/Targets/WebAssembly.cpp   | 1 +
 llvm/lib/Target/WebAssembly/WebAssembly.td| 3 ++-
 llvm/test/CodeGen/WebAssembly/fpclamptosat.ll | 2 +-
 llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll | 2 +-
 llvm/test/MC/WebAssembly/basic-assembly-errors.s  | 2 +-
 llvm/test/MC/WebAssembly/basic-assembly.s | 4 ++--
 llvm/test/MC/WebAssembly/data-section.s   | 8 
 llvm/test/MC/WebAssembly/objdump.s| 2 +-
 llvm/test/MC/WebAssembly/type-index.s | 4 ++--
 llvm/test/MC/WebAssembly/wasm64.s | 4 ++--
 11 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8a136aae5489a8c..1cca24a70ca4f94 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -453,6 +453,8 @@ AIX Support
 
 WebAssembly Support
 ^^^
+The -mcpu=generic configuration now enables -nontrapping-fptoint. This
+proposal is standardized and available in all major engines.
 
 AVR Support
 ^^^
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index f1c925d90cb649f..791c8c29fc6bcad 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -158,6 +158,7 @@ bool WebAssemblyTargetInfo::initFeatureMap(
 Features["multimemory"] = true;
 setSIMDLevel(Features, SIMD128, true);
   } else if (CPU == "generic") {
+Features["nontrapping-fptoint"] = true;
 Features["sign-ext"] = true;
 Features["mutable-globals"] = true;
   }
diff --git a/llvm/lib/Target/WebAssembly/WebAssembly.td 
b/llvm/lib/Target/WebAssembly/WebAssembly.td
index d538197450b65b0..efae460b6faa9bf 100644
--- a/llvm/lib/Target/WebAssembly/WebAssembly.td
+++ b/llvm/lib/Target/WebAssembly/WebAssembly.td
@@ -107,7 +107,8 @@ def : ProcessorModel<"mvp", NoSchedModel, []>;
 // consideration given to available support in relevant engines and tools, and
 // the importance of the features.
 def : ProcessorModel<"generic", NoSchedModel,
-  [FeatureSignExt, FeatureMutableGlobals]>;
+  [FeatureNontrappingFPToInt, FeatureSignExt,
+   FeatureMutableGlobals]>;
 
 // Latest and greatest experimental version of WebAssembly. Bugs included!
 def : ProcessorModel<"bleeding-edge", NoSchedModel,
diff --git a/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll 
b/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
index 58e3f0dc2a93c0b..78cc9c1f8e6da90 100644
--- a/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
+++ b/llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=wasm32-unknown-unknown 
-mattr=+simd128,+nontrapping-fptoint | FileCheck %s
+; RUN: llc < %s -mtriple=wasm32-unknown-unknown -mattr=+simd128 | FileCheck %s
 
 ; i32 saturate
 
diff --git a/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll 
b/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
index 8f85575c1cf4312..d3321e771f13946 100644
--- a/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
+++ b/llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=wasm32-unknown-unknown 
-mattr=+simd128,+nontrapping-fptoint | FileCheck %s
+; RUN: llc < %s -mtriple=wasm32-unknown-unknown -mattr=+simd128 | FileCheck %s
 
 ; i32 saturate
 
diff --git a/llvm/test/MC/WebAssembly/basic-assembly-errors.s 
b/llvm/test/MC/WebAssembly/basic-assembly-errors.s
index aab3b5b1a9028e0..cd063b69b4840d9 100644
--- a/llvm/test/MC/WebAssembly/basic-assembly-errors.s
+++ b/llvm/test/MC/WebAssembly/basic-assembly-errors.s
@@ -1,4 +1,4 @@
-# RUN: not llvm-mc -triple=wasm32-unknown-unknown 
-mattr=+simd128,+nontrapping-fptoint,+exception-handling %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -triple=wasm32-unknown-unknown 
-mattr=+simd128,+exception-handling %s 2>&1 | FileCheck %s
 
 # CHECK: invalid operand for instruction
 # (must be 0.0 or similar)
diff --git a/llvm/test/MC/WebAssembly/basic-assembly.s 
b/llvm/test/MC/WebAssembly/basic-assembly.s
index 769cd7edfa8a3e5..97233ac23d8324e 100644
--- a/llvm/test/MC/WebAssembly/basic-assembly.s
+++ b/llvm/test/MC/WebAssembly/basic-ass

[clang] [WebAssembly] Update generic CPU configuration to include nontrapping-fptoint (PR #67459)

2023-09-26 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 resolved 
https://github.com/llvm/llvm-project/pull/67459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Update generic CPU configuration to include nontrapping-fptoint (PR #67459)

2023-09-26 Thread Sam Clegg via cfe-commits

sbc100 wrote:

Oh I see I think the issue was Safari: https://webassembly.org/roadmap/.  Looks 
like this requires Safari 15 :(

https://github.com/llvm/llvm-project/pull/67459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Ensure NoTrapAfterNoreturn is false for the wasm backend (PR #65876)

2023-09-27 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> But `--no-trap-after-noreturn` didn't exist before, so there was no way to 
> specify that from the command line. You _created_ it, originally in this PR, 
> and then the split-off PR in #67051. If this is a bugfix, it sounds like you 
> are fixing a bug of your own making.

I think perhaps the misunderstanding here is that `NoTrapAfterNoreturn` was 
usable/settable by compilers such as rust via the LLVM API, even though 
`--no-trap-after-noreturn` didn't exist in llvm itself?

So adding this option just allows us to test something that wasn't testable, 
but was exposed via the API?  Is that right?

https://github.com/llvm/llvm-project/pull/65876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Ensure NoTrapAfterNoreturn is false for the wasm backend (PR #65876)

2023-09-27 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> But `--no-trap-after-noreturn` didn't exist before, so there was no way to 
> specify that from the command line. You _created_ it, originally in this PR, 
> and then the split-off PR in #67051. If this is a bugfix, it sounds like you 
> are fixing a bug of your own making.

I think perhaps the misunderstanding here is that `NoTrapAfterNoreturn` was 
usable/settable by compilers such as rust via the LLVM API, even though 
`--no-trap-after-noreturn` didn't exist in llvm itself?

So adding this option just allows us to test something that wasn't testable, 
but was exposed via the API?  Is that right?

https://github.com/llvm/llvm-project/pull/65876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 989ce06 - [clang][WebAssembly] Link crt1 even in case of -shared

2023-08-14 Thread Sam Clegg via cfe-commits

Author: YAMAMOTO Takashi
Date: 2023-08-14T09:36:44-07:00
New Revision: 989ce069a4638fd561bebc95f478ca9e45154fec

URL: 
https://github.com/llvm/llvm-project/commit/989ce069a4638fd561bebc95f478ca9e45154fec
DIFF: 
https://github.com/llvm/llvm-project/commit/989ce069a4638fd561bebc95f478ca9e45154fec.diff

LOG: [clang][WebAssembly] Link crt1 even in case of -shared

This allows -mexec-model=reactor -shared produces a library module
with _initialize entrypoint, which is preferrable over __wasm_call_ctors.

This partially reverts https://reviews.llvm.org/D153293

Discussion: https://github.com/dicej/component-linking-demo/issues/3

Reviewed By: sbc100

Differential Revision: https://reviews.llvm.org/D156205

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 36bed3166ff3c6..2098a68cbc6e56 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -77,31 +77,43 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
-  const char *Crt1 = "crt1.o";
+  bool IsCommand = true;
+  const char *Crt1;
   const char *Entry = nullptr;
 
-  // If crt1-command.o exists, it supports new-style commands, so use it.
-  // Otherwise, use the old crt1.o. This is a temporary transition measure.
-  // Once WASI libc no longer needs to support LLVM versions which lack
-  // support for new-style command, it can make crt1.o the same as
-  // crt1-command.o. And once LLVM no longer needs to support WASI libc
-  // versions before that, it can switch to using crt1-command.o.
-  if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
-Crt1 = "crt1-command.o";
+  // When -shared is specified, use the reactor exec model unless
+  // specified otherwise.
+  if (Args.hasArg(options::OPT_shared))
+IsCommand = false;
 
   if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
 StringRef CM = A->getValue();
 if (CM == "command") {
-  // Use default values.
+  IsCommand = true;
 } else if (CM == "reactor") {
-  Crt1 = "crt1-reactor.o";
-  Entry = "_initialize";
+  IsCommand = false;
 } else {
   ToolChain.getDriver().Diag(diag::err_drv_invalid_argument_to_option)
   << CM << A->getOption().getName();
 }
   }
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, 
options::OPT_shared))
+
+  if (IsCommand) {
+// If crt1-command.o exists, it supports new-style commands, so use it.
+// Otherwise, use the old crt1.o. This is a temporary transition measure.
+// Once WASI libc no longer needs to support LLVM versions which lack
+// support for new-style command, it can make crt1.o the same as
+// crt1-command.o. And once LLVM no longer needs to support WASI libc
+// versions before that, it can switch to using crt1-command.o.
+Crt1 = "crt1.o";
+if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
+  Crt1 = "crt1-command.o";
+  } else {
+Crt1 = "crt1-reactor.o";
+Entry = "_initialize";
+  }
+
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
   if (Entry) {
 CmdArgs.push_back(Args.MakeArgString("--entry"));

diff  --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index 8e4e749df01440..f950283ec42aa0 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -33,19 +33,19 @@
 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
-// -shared should be passed through to `wasm-ld` and not include crt1.o with a 
known OS.
+// -shared should be passed through to `wasm-ld` and include crt1-reactor.o 
with a known OS.
 
-// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN: %clang -### -shared -mexec-model=reactor --target=wasm32-wasi 
--sysroot=/foo %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
 // LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" 
"[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1-reactor.o" 
"--entry" "_initialize" "-shared" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
-// -shared should be passed through to `wasm-ld` and not include crt1.o with 
an unknown OS.
+// -shared should be passed through to `wasm-ld` and include crt1-

[clang] 0731372 - [clang] Allow -DDEFAULT_SYSROOT to be a relative path

2020-03-26 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2020-03-26T13:48:57-07:00
New Revision: 0731372ee25c8db93e0d976db4be4ffb7c7329c5

URL: 
https://github.com/llvm/llvm-project/commit/0731372ee25c8db93e0d976db4be4ffb7c7329c5
DIFF: 
https://github.com/llvm/llvm-project/commit/0731372ee25c8db93e0d976db4be4ffb7c7329c5.diff

LOG: [clang] Allow -DDEFAULT_SYSROOT to be a relative path

In this case we interpret the path as relative the clang driver binary.

This allows SDKs to be built that include clang along with a custom
sysroot without requiring users to specify --sysroot to point to the
directory where they installed the SDK.

See https://github.com/WebAssembly/wasi-sdk/issues/58

Differential Revision: https://reviews.llvm.org/D76653

Added: 


Modified: 
clang/CMakeLists.txt
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index db82d87b181f..7809d6529195 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -226,7 +226,7 @@ set(C_INCLUDE_DIRS "" CACHE STRING
   "Colon separated list of directories clang will search for headers.")
 
 set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
-set(DEFAULT_SYSROOT "" CACHE PATH
+set(DEFAULT_SYSROOT "" CACHE STRING
   "Default  to all compiler invocations for --sysroot=." )
 
 set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e3b7793ca266..4afe3e635fc8 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -140,6 +140,13 @@ Driver::Driver(StringRef ClangExecutable, StringRef 
TargetTriple,
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if ((!SysRoot.empty()) && llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> P(InstalledDir);
+llvm::sys::path::append(P, SysRoot);
+SysRoot = std::string(P);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 881d877 - [WebAssembly] Add new `export_name` clang attribute for controlling wasm export names

2019-12-11 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2019-12-11T11:54:57-08:00
New Revision: 881d877846e2904c731d616731969421ce8cc825

URL: 
https://github.com/llvm/llvm-project/commit/881d877846e2904c731d616731969421ce8cc825
DIFF: 
https://github.com/llvm/llvm-project/commit/881d877846e2904c731d616731969421ce8cc825.diff

LOG: [WebAssembly] Add new `export_name` clang attribute for controlling wasm 
export names

This is equivalent to the existing `import_name` and `import_module`
attributes which control the import names in the final wasm binary
produced by lld.

This maps the existing

This attribute currently requires a string rather than using the
symbol name for a couple of reasons:

1. Avoid confusion with static and dynamic linking which is
   based on symbol name.  Exporting a function from a wasm module using
   this directive is orthogonal to both static and dynamic linking.
2. Avoids name mangling.

Differential Revision: https://reviews.llvm.org/D70520

Added: 
clang/test/CodeGen/wasm-export-name.c
lld/test/wasm/export-name.ll
llvm/test/CodeGen/WebAssembly/export-name.ll
llvm/test/MC/WebAssembly/export-name.s

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
lld/docs/WebAssembly.rst
lld/wasm/InputChunks.h
lld/wasm/Writer.cpp
llvm/include/llvm/BinaryFormat/Wasm.h
llvm/include/llvm/MC/MCSymbolWasm.h
llvm/include/llvm/Object/Wasm.h
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 40e180f343e7..47d9e641b178 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1600,6 +1600,14 @@ def BPFPreserveAccessIndex : InheritableAttr,
   let LangOpts = [COnly];
 }
 
+def WebAssemblyExportName : InheritableAttr,
+TargetSpecificAttr {
+  let Spellings = [Clang<"export_name">];
+  let Args = [StringArgument<"ExportName">];
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+}
+
 def WebAssemblyImportModule : InheritableAttr,
   TargetSpecificAttr {
   let Spellings = [Clang<"import_module">];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 764ac2485350..c632e52b28d1 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4101,6 +4101,21 @@ For more information see
 or `msvc documentation `_.
 }]; }
 
+def WebAssemblyExportNameDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``__attribute__((export_name()))``
+attribute for the WebAssembly target. This attribute may be attached to a
+function declaration, where it modifies how the symbol is to be exported
+from the linked WebAssembly.
+
+WebAssembly functions are exported via string name. By default when a symbol
+is exported, the export name for C/C++ symbols are the same as their C/C++
+symbol names. This attribute can be used to override the default behavior, and
+request a specific string name be used instead.
+  }];
+}
+
 def WebAssemblyImportModuleDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 33e7b18d8393..9fd4a5fb17a7 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -779,6 +779,12 @@ class WebAssemblyTargetCodeGenInfo final : public 
TargetCodeGenInfo {
 B.addAttribute("wasm-import-name", Attr->getImportName());
 Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
   }
+  if (const auto *Attr = FD->getAttr()) {
+llvm::Function *Fn = cast(GV);
+llvm::AttrBuilder B;
+B.addAttribute("wasm-export-name", Attr->getExportName());
+Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  }
 }
 
 if (auto *FD = dyn_cast_or_null(D)) {

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 60a998036899..e83688c46be1 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5754,6 +5754,28 @@ static void handleBPFPreserveAccessIndexAttr(Sema &S, 
Decl *D,
   Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
 }
 
+static void handleWebAssembly

[clang] 0a1e349 - [WebAssembly] Setting export_name implies llvm.used

2019-12-16 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2019-12-16T14:48:38-08:00
New Revision: 0a1e349a7933f7880971533175e11b4bfd22bd53

URL: 
https://github.com/llvm/llvm-project/commit/0a1e349a7933f7880971533175e11b4bfd22bd53
DIFF: 
https://github.com/llvm/llvm-project/commit/0a1e349a7933f7880971533175e11b4bfd22bd53.diff

LOG: [WebAssembly] Setting export_name implies llvm.used

This change updates the clang front end to add symbols to llvm.used
when they have explicit export_name attribute.

Differential Revision: https://reviews.llvm.org/D71493

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/wasm-export-name.c

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e83688c46be1..678320487453 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@ static void handleWebAssemblyExportNameAttr(Sema &S, Decl 
*D, const ParsedAttr &
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {

diff  --git a/clang/test/CodeGen/wasm-export-name.c 
b/clang/test/CodeGen/wasm-export-name.c
index b662a272cbac..f2556155dd4c 100644
--- a/clang/test/CodeGen/wasm-export-name.c
+++ b/clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@ int foo(void) {
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo 
to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329323 - Fix typo in comment -fmath-errno=0 -> -fno-math-errno

2018-04-05 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Apr  5 10:44:08 2018
New Revision: 329323

URL: http://llvm.org/viewvc/llvm-project?rev=329323&view=rev
Log:
Fix typo in comment -fmath-errno=0 -> -fno-math-errno

The former is not a valid clang argument

Differential Revision: https://reviews.llvm.org/D45102

Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=329323&r1=329322&r2=329323&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Thu Apr  5 10:44:08 2018
@@ -89,7 +89,7 @@
 //  S:N: -> similar to the s:N: attribute, but the function is like vscanf
 //  in that it accepts its arguments as a va_list rather than
 //  through an ellipsis
-//  e -> const, but only when -fmath-errno=0
+//  e -> const, but only when -fno-math-errno
 //  j -> returns_twice (like setjmp)
 //  u -> arguments are not evaluated for their side-effects
 //  FIXME: gcc has nonnull


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316719 - [WebAssembly] Include libclang_rt.builtins in the standard way

2017-10-26 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Oct 26 17:26:07 2017
New Revision: 316719

URL: http://llvm.org/viewvc/llvm-project?rev=316719&view=rev
Log:
[WebAssembly] Include libclang_rt.builtins in the standard way

Differential Revision: https://reviews.llvm.org/D39218

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=316719&r1=316718&r2=316719&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Oct 26 17:26:07 2017
@@ -309,7 +309,13 @@ static StringRef getArchNameForCompilerR
 
 std::string ToolChain::getCompilerRTPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  StringRef OSLibName;
+  if (Triple.isOSFreeBSD())
+OSLibName = "freebsd";
+  else if (Triple.isOSBinFormatWasm())
+OSLibName = "wasm";
+  else
+OSLibName = getOS();
   llvm::sys::path::append(Path, "lib", OSLibName);
   return Path.str();
 }

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=316719&r1=316718&r2=316719&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Oct 26 17:26:07 2017
@@ -1027,15 +1027,7 @@ void tools::AddRunTimeLibs(const ToolCha
 
   switch (RLT) {
   case ToolChain::RLT_CompilerRT:
-switch (TC.getTriple().getOS()) {
-default:
-  llvm_unreachable("unsupported OS");
-case llvm::Triple::Win32:
-case llvm::Triple::Linux:
-case llvm::Triple::Fuchsia:
-  CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
-  break;
-}
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 break;
   case ToolChain::RLT_Libgcc:
 // Make sure libgcc is not used under MSVC environment by default

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=316719&r1=316718&r2=316719&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Thu Oct 26 17:26:07 2017
@@ -61,7 +61,7 @@ void wasm::Linker::ConstructJob(Compilat
 CmdArgs.push_back("-allow-undefined-file");
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("wasm.syms")));
 CmdArgs.push_back("-lc");
-CmdArgs.push_back("-lcompiler_rt");
+AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
   CmdArgs.push_back("-o");

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=316719&r1=316718&r2=316719&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Oct 26 17:26:07 2017
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316725 - Fix test/Driver/wasm-toolchain.c on windows

2017-10-26 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Oct 26 18:20:16 2017
New Revision: 316725

URL: http://llvm.org/viewvc/llvm-project?rev=316725&view=rev
Log:
Fix test/Driver/wasm-toolchain.c on windows

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=316725&r1=316724&r2=316725&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Oct 26 18:20:16 2017
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316777 - [WebAssembly] Add crt1.o with calling lld

2017-10-27 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Fri Oct 27 11:10:19 2017
New Revision: 316777

URL: http://llvm.org/viewvc/llvm-project?rev=316777&view=rev
Log:
[WebAssembly] Add crt1.o with calling lld

Also, for OS unknown targets like wasm, don't include
'unknown' in the library path. This is a fix for rL316719.

Differential Revision: https://reviews.llvm.org/D39354

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=316777&r1=316776&r2=316777&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Oct 27 11:10:19 2017
@@ -309,14 +309,12 @@ static StringRef getArchNameForCompilerR
 
 std::string ToolChain::getCompilerRTPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName;
-  if (Triple.isOSFreeBSD())
-OSLibName = "freebsd";
-  else if (Triple.isOSBinFormatWasm())
-OSLibName = "wasm";
-  else
-OSLibName = getOS();
-  llvm::sys::path::append(Path, "lib", OSLibName);
+  if (Triple.isOSUnknown()) {
+llvm::sys::path::append(Path, "lib");
+  } else {
+StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+llvm::sys::path::append(Path, "lib", OSLibName);
+  }
   return Path.str();
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=316777&r1=316776&r2=316777&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Fri Oct 27 11:10:19 2017
@@ -49,6 +49,9 @@ void wasm::Linker::ConstructJob(Compilat
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=316777&r1=316776&r2=316777&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Fri Oct 27 11:10:19 2017
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 55e199a - [clang][WebAssembly] Support wasm32-wasi shared libraries

2023-06-26 Thread Sam Clegg via cfe-commits

Author: Joel Dice
Date: 2023-06-26T10:31:40-07:00
New Revision: 55e199a2c9f4b218499733d60129deffa0a025fe

URL: 
https://github.com/llvm/llvm-project/commit/55e199a2c9f4b218499733d60129deffa0a025fe
DIFF: 
https://github.com/llvm/llvm-project/commit/55e199a2c9f4b218499733d60129deffa0a025fe.diff

LOG: [clang][WebAssembly] Support wasm32-wasi shared libraries

This adds support for Emscripten-style shared libraries [1] to
non-emscripten targets, such as `wasm32-wasi`.  Previously, only static
linking was supported, and the `-shared` and `-fPIC` flags were simply
ignored.  Now both flags are honored.

Since WASI runtimes do not necessarily include JavaScript support, we
cannot rely on the JS-based Emscripten linker to link shared libraries.
Instead, we link them using the Component Model proposal [2].

We have prototyped shared library support in `wasi-sdk` [3] and put
together a demo [4] which uses a patched version of `wit-component` [5]
to link libraries using the Component Model.  We plan to submit the
required changes upstream to the respective repositories in the next
week or two.

[1] https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
[2] 
https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md
[3] https://github.com/dicej/wasi-sdk/tree/dynamic-linking
[4] https://github.com/dicej/component-linking-demo
[5] 
https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-component

Signed-off-by: Joel Dice 

Reviewed By: sbc100

Differential Revision: https://reviews.llvm.org/D153293

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 055aa9008b03b..c022e9ffb6604 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -727,6 +727,12 @@ AIX Support
 
 WebAssembly Support
 ^^^
+- Shared library support (and PIC code generation) for WebAssembly is no longer
+  limited to the Emscripten target OS and now works with other targets such as
+  wasm32-wasi.  Note that the `format
+  
`_
+  is not yet stable and may change between LLVM versions.  Also, WASI does not
+  yet have facilities to load dynamic libraries.
 
 AVR Support
 ^^^

diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 016b70b1c2ede..fb9c8e4910e8b 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -101,13 +101,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   << CM << A->getOption().getName();
 }
   }
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, 
options::OPT_shared))
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
   if (Entry) {
 CmdArgs.push_back(Args.MakeArgString("--entry"));
 CmdArgs.push_back(Args.MakeArgString(Entry));
   }
 
+  if (Args.hasArg(options::OPT_shared))
+CmdArgs.push_back(Args.MakeArgString("-shared"));
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {

diff  --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index bfe696d7846e7..909d27f0f2d9c 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -33,6 +33,20 @@
 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// -shared should be passed through to `wasm-ld` and not include crt1.o with a 
known OS.
+
+// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
+// LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" 
"[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
+// -shared should be passed through to `wasm-ld` and not include crt1.o with 
an unknown OS.
+
+// RUN: %clang -### -shared --target=wasm32-unknown-unknown --sysroot=/foo %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_UNKNOWN_SHARED %s
+// LINK_UNKNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_UNKNOWN_SHARED: wasm-ld{{.*}}" "-shared" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C link command-line with optimization with known OS.
 
 // RUN: %clang -### -O2 --target=wasm32-wasi 

r322321 - [WebAssembly] Remove `-allow-undefined-file wasm.syms` from linker args

2018-01-11 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Jan 11 14:33:50 2018
New Revision: 322321

URL: http://llvm.org/viewvc/llvm-project?rev=322321&view=rev
Log:
[WebAssembly] Remove `-allow-undefined-file wasm.syms` from linker args

See: https://github.com/WebAssembly/tool-conventions/issues/35

Differential Revision: https://reviews.llvm.org/D41923

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=322321&r1=322320&r2=322321&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Thu Jan 11 14:33:50 2018
@@ -62,8 +62,6 @@ void wasm::Linker::ConstructJob(Compilat
 if (Args.hasArg(options::OPT_pthread))
   CmdArgs.push_back("-lpthread");
 
-CmdArgs.push_back("-allow-undefined-file");
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("wasm.syms")));
 CmdArgs.push_back("-lc");
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=322321&r1=322320&r2=322321&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Jan 11 14:33:50 2018
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r322382 - [WebAssembly] Support -stdlib=libc++ switch

2018-01-12 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Fri Jan 12 09:54:49 2018
New Revision: 322382

URL: http://llvm.org/viewvc/llvm-project?rev=322382&view=rev
Log:
[WebAssembly] Support -stdlib=libc++ switch

Referenced implementation from Fuchsia and Darwin Toolchain.
Still only support CST_Libcxx.  Now checks that the argument
is really '-stdlib=libc++', and display error.

Also, now will pass -lc++ and -lc++abi to the linker.

Patch by Patrick Cheng!

Differential Revision: https://reviews.llvm.org/D41937

Added:
cfe/trunk/test/Driver/wasm-toolchain.cpp   (with props)
Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=322382&r1=322381&r2=322382&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Fri Jan 12 09:54:49 2018
@@ -11,6 +11,7 @@
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 
@@ -117,6 +118,12 @@ ToolChain::RuntimeLibType WebAssembly::G
 }
 
 ToolChain::CXXStdlibType WebAssembly::GetCXXStdlibType(const ArgList &Args) 
const {
+  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
+StringRef Value = A->getValue();
+if (Value != "libc++")
+  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+  << A->getAsString(Args);
+  }
   return ToolChain::CST_Libcxx;
 }
 
@@ -134,6 +141,19 @@ void WebAssembly::AddClangCXXStdlibInclu
  getDriver().SysRoot + "/include/c++/v1");
 }
 
+void WebAssembly::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const 
{
+
+  switch (GetCXXStdlibType(Args)) {
+  case ToolChain::CST_Libcxx:
+CmdArgs.push_back("-lc++");
+CmdArgs.push_back("-lc++abi");
+break;
+  case ToolChain::CST_Libstdcxx:
+llvm_unreachable("invalid stdlib name");
+  }
+}
+
 std::string WebAssembly::getThreadModel() const {
   // The WebAssembly MVP does not yet support threads; for now, use the
   // "single" threading model, which lowers atomics to non-atomic operations.

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=322382&r1=322381&r2=322382&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Fri Jan 12 09:54:49 2018
@@ -62,6 +62,8 @@ private:
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
   const char *getDefaultLinker() const override {

Added: cfe/trunk/test/Driver/wasm-toolchain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.cpp?rev=322382&view=auto
==
--- cfe/trunk/test/Driver/wasm-toolchain.cpp (added)
+++ cfe/trunk/test/Driver/wasm-toolchain.cpp Fri Jan 12 09:54:49 2018
@@ -0,0 +1,36 @@
+// A basic clang -cc1 command-line. WebAssembly is somewhat special in
+// enabling -ffunction-sections, -fdata-sections, and -fvisibility=hidden by
+// default.
+
+// RUN: %clang++ %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
2>&1 | FileCheck -check-prefix=CC1 %s
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}} "-ffunction-sections" "-fdata-sections"
+
+// Ditto, but ensure that a user -fno-function-sections disables the
+// default -ffunction-sections.
+
+// RUN: %clang++ %s -### -target wasm32-unknown-unknown -fno-function-sections 
2>&1 | FileCheck -check-prefix=NO_FUNCTION_SECTIONS %s
+// NO_FUNCTION_SECTIONS-NOT: function-sections
+
+// Ditto, but ensure that a user -fno-data-sections disables the
+// default -fdata-sections.
+
+// RUN: %clang++ %s -### -target wasm32-unknown-unknown -fno-data-sections 
2>&1 | FileCheck -check-prefix=NO_DATA_SECTIONS %s
+// NO_DATA_SECTIONS-NOT: data-sections
+
+// Ditto, but ensure that a user -fvisibility=default disables the default
+// -fvisibility=hidden.
+
+// RUN: %clang++ %s -### -target wasm32-unknown-unknown -fvisibility=default 
2>&1 | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
+// FVISIBILITY_DEFAULT-NOT: hidden
+
+// A basic C++ link command-line.
+
+// RUN: %clang++ -### -no-canonical-prefixes -target wasm32-unknown-unknow

r322880 - Convert comment to C-style to prevent warning

2018-01-18 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Jan 18 11:31:33 2018
New Revision: 322880

URL: http://llvm.org/viewvc/llvm-project?rev=322880&view=rev
Log:
Convert comment to C-style to prevent warning

Modified:
cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=322880&r1=322879&r2=322880&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jan 18 11:31:33 2018
@@ -739,7 +739,7 @@ static CXString CursorToText(CXCursor Cu
   }
   }
   assert(0 && "unknown display type"); /* no llvm_unreachable in C. */
-  // Set to NULL to prevent uninitialized variable warnings.
+  /* Set to NULL to prevent uninitialized variable warnings. */
   text.data = NULL;
   text.private_flags = 0;
   return text;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r323897 - [WebAssembly] Don't pass -ffunction-section/-fdata-sections

2018-01-31 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Wed Jan 31 10:55:22 2018
New Revision: 323897

URL: http://llvm.org/viewvc/llvm-project?rev=323897&view=rev
Log:
[WebAssembly] Don't pass -ffunction-section/-fdata-sections

llvm currently forces both of these to true to passing them
is redundant.

Differential Revision: https://reviews.llvm.org/D37831

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=323897&r1=323896&r2=323897&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Jan 31 10:55:22 2018
@@ -363,12 +363,9 @@ unsigned tools::getLTOParallelism(const
   return Parallelism;
 }
 
-// CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
-// default.
+// CloudABI uses -ffunction-sections and -fdata-sections by default.
 bool tools::isUseSeparateSections(const llvm::Triple &Triple) {
-  return Triple.getOS() == llvm::Triple::CloudABI ||
- Triple.getArch() == llvm::Triple::wasm32 ||
- Triple.getArch() == llvm::Triple::wasm64;
+  return Triple.getOS() == llvm::Triple::CloudABI;
 }
 
 void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=323897&r1=323896&r2=323897&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan 31 10:55:22 2018
@@ -1,21 +1,8 @@
 // A basic clang -cc1 command-line. WebAssembly is somewhat special in
-// enabling -ffunction-sections, -fdata-sections, and -fvisibility=hidden by
-// default.
+// enabling -fvisibility=hidden by default.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}} "-ffunction-sections" "-fdata-sections"
-
-// Ditto, but ensure that a user -fno-function-sections disables the
-// default -ffunction-sections.
-
-// RUN: %clang %s -### -target wasm32-unknown-unknown -fno-function-sections 
2>&1 | FileCheck -check-prefix=NO_FUNCTION_SECTIONS %s
-// NO_FUNCTION_SECTIONS-NOT: function-sections
-
-// Ditto, but ensure that a user -fno-data-sections disables the
-// default -fdata-sections.
-
-// RUN: %clang %s -### -target wasm32-unknown-unknown -fno-data-sections 2>&1 
| FileCheck -check-prefix=NO_DATA_SECTIONS %s
-// NO_DATA_SECTIONS-NOT: data-sections
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}}
 
 // Ditto, but ensure that a user -fvisibility=default disables the default
 // -fvisibility=hidden.

Modified: cfe/trunk/test/Driver/wasm-toolchain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.cpp?rev=323897&r1=323896&r2=323897&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.cpp (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.cpp Wed Jan 31 10:55:22 2018
@@ -1,21 +1,8 @@
 // A basic clang -cc1 command-line. WebAssembly is somewhat special in
-// enabling -ffunction-sections, -fdata-sections, and -fvisibility=hidden by
-// default.
+// enabling -fvisibility=hidden by default.
 
 // RUN: %clangxx %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}} "-ffunction-sections" "-fdata-sections"
-
-// Ditto, but ensure that a user -fno-function-sections disables the
-// default -ffunction-sections.
-
-// RUN: %clangxx %s -### -target wasm32-unknown-unknown -fno-function-sections 
2>&1 | FileCheck -check-prefix=NO_FUNCTION_SECTIONS %s
-// NO_FUNCTION_SECTIONS-NOT: function-sections
-
-// Ditto, but ensure that a user -fno-data-sections disables the
-// default -fdata-sections.
-
-// RUN: %clangxx %s -### -target wasm32-unknown-unknown -fno-data-sections 
2>&1 | FileCheck -check-prefix=NO_DATA_SECTIONS %s
-// NO_DATA_SECTIONS-NOT: data-sections
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}}
 
 // Ditto, but ensure that a user -fvisibility=default disables the default
 // -fvisibility=hidden.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302558 - [WebAssembly] Fix location and -flavor when running lld

2017-05-09 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue May  9 12:47:50 2017
New Revision: 302558

URL: http://llvm.org/viewvc/llvm-project?rev=302558&view=rev
Log:
[WebAssembly] Fix location and -flavor when running lld

Add the toolchain installation directory to the program
path so that lld can be found.

Change -flavor to wasm.  Although this new flavor hasn't
yet landed in upstream lld yet there are no point in
passing wasm objects the gnu flavor.

Differential Revision: https://reviews.llvm.org/D32976

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=302558&r1=302557&r2=302558&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Tue May  9 12:47:50 2017
@@ -42,7 +42,7 @@ void wasm::Linker::ConstructJob(Compilat
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("ld");
+  CmdArgs.push_back("wasm");
 
   // Enable garbage collection of unused input sections by default, since code
   // size is of particular importance. This is significantly facilitated by
@@ -101,6 +101,9 @@ WebAssembly::WebAssembly(const Driver &D
   : ToolChain(D, Triple, Args) {
 
   assert(Triple.isArch32Bit() != Triple.isArch64Bit());
+
+  getProgramPaths().push_back(getDriver().getInstalledDir());
+
   getFilePaths().push_back(
   getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302569 - [WebAssembly] Fix failing wasm-toolchain test

2017-05-09 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue May  9 13:44:23 2017
New Revision: 302569

URL: http://llvm.org/viewvc/llvm-project?rev=302569&view=rev
Log:
[WebAssembly] Fix failing wasm-toolchain test

This test was broken in r302558.

Differential Revision: https://reviews.llvm.org/D33015

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=302569&r1=302568&r2=302569&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Tue May  9 13:44:23 2017
@@ -27,18 +27,18 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "ld" "-L/foo/lib32" "crt1.o" "crti.o" "[[temp]]" 
"-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib32" "crt1.o" "crti.o" 
"[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // A basic C link command-line with optimization. WebAssembly is somewhat
 // special in enabling --gc-sections by default.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "ld" "--gc-sections" "-L/foo/lib32" "crt1.o" 
"crti.o" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // Ditto, but ensure that a user --no-gc-sections comes after the
 // default --gc-sections.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -Wl,--no-gc-sections %s 2>&1 | FileCheck 
-check-prefix=NO_GC_SECTIONS %s
 // NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "ld" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" 
"-o" "a.out"
+// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" 
"-o" "a.out"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Sam Clegg via cfe-commits

sbc100 wrote:

After this lands does that mean that all object files will have `multi-value` 
in the features section?  Or only object files that actually use `mutli-value`? 
   

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Sam Clegg via cfe-commits


@@ -147,19 +147,25 @@ void 
WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap &Features,
 bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
 const std::vector &FeaturesVec) const {
-  if (CPU == "bleeding-edge") {
-Features["nontrapping-fptoint"] = true;
+  auto addGenericFeatures = [&]() {
 Features["sign-ext"] = true;
+Features["mutable-globals"] = true;
+Features["reference-types"] = true;
+Features["multivalue"] = true;
+  };
+  auto addBleedingEdgeFeatures = [&]() {
+addGenericFeatures();
+Features["nontrapping-fptoint"] = true;

sbc100 wrote:

I'm a bit sad not to see this added, since this is the one that can actually 
improve codegen.   If we know we want to enable to this, is there any downside 
to doing two different rounds (i.e. are there advantages to waiting on this 
until we have the lowering pass in place?)

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Don't default to -mrelax-all for non-RISCV -O0 (PR #90013)

2024-04-26 Thread Sam Clegg via cfe-commits

sbc100 wrote:

This change seems to have caused a test in emscripten to starting failing with 
`argument unused during compilation: '-O2'`: 
https://github.com/emscripten-core/emscripten/pull/21841.

Is that an intended side effect of this change?  The fix on our end seems 
reasonable but posting here just in case.

https://github.com/llvm/llvm-project/pull/90013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add flag to opt out of wasm-opt (PR #95208)

2024-07-10 Thread Sam Clegg via cfe-commits

sbc100 wrote:

I think should never not be running wasm-opt when the linker is  
wasm-component-ld.   Thats not going to work, at least not any time soon.

How to integrate wasm-opt into wasm-component-ld is a good question.  I imagine 
@alexcrichton has some ideas in that area.

https://github.com/llvm/llvm-project/pull/95208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Disable running `wasm-opt` on components (PR #98373)

2024-07-10 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 approved this pull request.

Can we write a test for this?

https://github.com/llvm/llvm-project/pull/98373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Disable running `wasm-opt` on components (PR #98373)

2024-07-11 Thread Sam Clegg via cfe-commits

sbc100 wrote:

I think the problem with creating a dummy shell script is that it would need to 
work on windows too.. I guess it would be better to have test that run on some 
platforms that no test at all.

In any case, I'm OK with having this land as-is for now, since this is feature 
that is already untested. 

https://github.com/llvm/llvm-project/pull/98373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Disable running `wasm-opt` on components (PR #98373)

2024-07-11 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 approved this pull request.


https://github.com/llvm/llvm-project/pull/98373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Pipelines] Do not run CoroSplit and CoroCleanup in LTO pre-link pipeline (PR #90310)

2024-04-30 Thread Sam Clegg via cfe-commits

sbc100 wrote:

This change seems to causing the auto-roller for emscripten to fail due to a 
crash in LTO.  See 
https://ci.chromium.org/ui/p/emscripten-releases/builders/luci.emscripten-releases.ci/linux-test-suites

```
PromoteIntegerOperand Op #3: t22: i32,ch = llvm.coro.subfn.addr t26, 
TargetConstant:i32<54>, t9, Constant:i8<0>

LLVM ERROR: Do not know how to promote this operator's operand!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  Program arguments: 
/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/wasm-ld -o test_val.wasm 
/tmp/emscripten_temp_54ryesgk/test_val_0.o -lembind-rtti 
-L/usr/local/google/home/sbc/dev/wasm/emscripten/cache/sysroot/lib/wasm32-emscripten/lto
 -lGL-getprocaddr -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt 
-lc++-noexcept -lc++abi-noexcept -lsockets -mllvm 
-combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm 
-disable-lsr /tmp/tmpgksompwplibemscripten_js_symbols.so --strip-debug 
-u__cxa_atexit --export=_emscripten_stack_alloc --export=__getTypeName 
--export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors 
--export=emscripten_stack_get_current --export=_emscripten_stack_restore 
--export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm 
--export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps 
--export-if-defined=__start_em_js --export-if-defined=__stop_em_js 
--export-if-defined=main --export-if-defined=__main_argc_argv --export-table -z 
stack-size=65536 --no-growable-memory --initial-heap=16777216 --no-entry 
--table-base=1 --global-base=1024
1.  Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.  Running pass 'WebAssembly Instruction Selection' on function 
'@_emval_coro_resume'
 #0 0x7f187817e048 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x17e048)
 #1 0x7f187817bcbe llvm::sys::RunSignalHandlers() 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x17bcbe)
 #2 0x7f187817e70d SignalHandler(int) Signals.cpp:0:0
 #3 0x7f1877d7b510 (/lib/x86_64-linux-gnu/libc.so.6+0x3c510)
 #4 0x7f1877dc916c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x7f1877d7b472 raise ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x7f1877d654b2 abort ./stdlib/abort.c:81:7
 #7 0x7f18780d497a llvm::report_fatal_error(llvm::Twine const&, bool) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0xd497a)
 #8 0x7f18780d47c6 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0xd47c6)
 #9 0x7f18749713e3 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/../lib/libLLVMSelectionDAG.so.19.0git+0x1713e3)
#10 0x7f187498ff79 llvm::DAGTypeLegalizer::run() 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/../lib/libLLVMSelectionDAG.so.19.0git+0x18ff79)
#11 0x7f18749953f7 llvm::SelectionDAG::LegalizeTypes() 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/../lib/libLLVMSelectionDAG.so.19.0git+0x1953f7)
#12 0x7f1874acba4f llvm::SelectionDAGISel::CodeGenAndEmitDAG() 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/../lib/libLLVMSelectionDAG.so.19.0git+0x2cba4f)
#13 0x7f1874aca101 
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/../lib/libLLVMSelectionDAG.so.19.0git+0x2ca101)
#14 0x7f1874ac6a63 
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/../lib/libLLVMSelectionDAG.so.19.0git+0x2c6a63)
#15 0x7f1875359b94 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/libLLVMCodeGen.so.19.0git+0x359b94)
#16 0x7f1875e97a1a llvm::FPPassManager::runOnFunction(llvm::Function&) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/libLLVMCore.so.19.0git+0x297a1a)
#17 0x7f1875e9fe22 llvm::FPPassManager::runOnModule(llvm::Module&) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/libLLVMCore.so.19.0git+0x29fe22)
#18 0x7f1875e9850f llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/libLLVMCore.so.19.0git+0x29850f)
#19 0x7f1877c24c62 codegen(llvm::lto::Config const&, llvm::TargetMachine*, 
std::__2::function>> (unsigned int, llvm::Twine 
const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) 
LTOBackend.cpp:0:0
#20 0x7f1877c23daf llvm::lto::backend(llvm::lto::Config const&, 
std::__2::function>> (unsigned int, llvm::Twine 
const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) 
(/usr/local/google/home/sbc/dev/wasm/llv

[clang] [llvm] [Pipelines] Do not run CoroSplit and CoroCleanup in LTO pre-link pipeline (PR #90310)

2024-04-30 Thread Sam Clegg via cfe-commits

sbc100 wrote:

The function being compiled in the crash looks like this one: 
https://github.com/emscripten-core/emscripten/blob/56547157a37e25fb31f9193461a2c88bdaa44385/system/lib/embind/bind.cpp#L66-L68

https://github.com/llvm/llvm-project/pull/90310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Pipelines][Coroutines] Tune coroutine passes only for ThinLTO pre-link pipeline (PR #90690)

2024-04-30 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 approved this pull request.

I'm not very familiar with this code, but it looks reasonable on the surface.

https://github.com/llvm/llvm-project/pull/90690
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent

2024-05-02 Thread Sam Clegg via cfe-commits

sbc100 wrote:

This change recently rolled into the emscripten SDK and seems to be breaking 
the build of regal.  I've not invistigated this yet, and its not our code:

```
em++ -c 
/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/regal/RegalIff.cpp
 -o 
/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports-builds/regal/regal/RegalIff.cpp.o
 -g -sSTRICT -Werror -O2 
-I/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src
 -DNDEBUG -DREGAL_LOG=0 -DREGAL_MISSING=0 -std=gnu++14 -fno-rtti 
-fno-exceptions -O3 
-I/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/regal
 
-I/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/lookup3
 
-I/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/boost
 -Wno-deprecated-register -Wno-unused-parameter
In file included from 
/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/regal/RegalIff.cpp:49:
In file included from 
/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/regal/RegalIff.h:80:
/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/regal/linear.h:585:26:
 error: no member named 'negate' in 'Vec4'; did you mean 'Negate'?
  585 |   Vec4 rv(*this); rv.negate(); return rv;
  |  ^~
  |  Negate
/usr/local/google/home/sbc/dev/wasm/emscripten/cache/ports/regal/regal-version_7/src/regal/linear.h:534:11:
 note: 'Negate' declared here
  534 | void  Negate() {
  |   ^
1 error generated.
```

https://github.com/llvm/llvm-project/pull/90152
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Define __USING_WASM_EXCEPTIONS__ for -fwasm-exceptions (PR #92604)

2024-05-17 Thread Sam Clegg via cfe-commits


@@ -1006,6 +1006,8 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
   else if (LangOpts.hasDWARFExceptions() &&
(TI.getTriple().isThumb() || TI.getTriple().isARM()))
 Builder.defineMacro("__ARM_DWARF_EH__");
+  else if (LangOpts.hasWasmExceptions() && TI.getTriple().isWasm())
+Builder.defineMacro("__USING_WASM_EXCEPTIONS__");

sbc100 wrote:

How about just calling this `__WASM_EXCEPTIONS__`?

https://github.com/llvm/llvm-project/pull/92604
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Define __USING_WASM_EXCEPTIONS__ for -fwasm-exceptions (PR #92604)

2024-05-17 Thread Sam Clegg via cfe-commits


@@ -1006,6 +1006,8 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
   else if (LangOpts.hasDWARFExceptions() &&
(TI.getTriple().isThumb() || TI.getTriple().isARM()))
 Builder.defineMacro("__ARM_DWARF_EH__");
+  else if (LangOpts.hasWasmExceptions() && TI.getTriple().isWasm())
+Builder.defineMacro("__USING_WASM_EXCEPTIONS__");

sbc100 wrote:

I see the `__USING_` prefix does predate out work on Wasm exceptions so there 
is some precedent.  

I see __USING_SJLJ_EXCEPTIONS__ dating all the way back to 2009: 
2f5c75e17dc0b2df841db396de22c35b95cb7f41.   However, I don't see any other 
predefined macros using the `__USING_` prefix, so it might be worth removing it 
now before it gets even harder to remove.

Presumably it would be quite easy for downstream toolchains to switch to using 
`__WASM_EXCEPTIONS__` either before or after this change lands.. and then 
remove the manual define at some point in the future.

https://github.com/llvm/llvm-project/pull/92604
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Define __USING_WASM_EXCEPTIONS__ for -fwasm-exceptions (PR #92604)

2024-05-17 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 edited https://github.com/llvm/llvm-project/pull/92604
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Define __USING_WASM_EXCEPTIONS__ for -fwasm-exceptions (PR #92604)

2024-05-17 Thread Sam Clegg via cfe-commits


@@ -1006,6 +1006,8 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
   else if (LangOpts.hasDWARFExceptions() &&
(TI.getTriple().isThumb() || TI.getTriple().isARM()))
 Builder.defineMacro("__ARM_DWARF_EH__");
+  else if (LangOpts.hasWasmExceptions() && TI.getTriple().isWasm())
+Builder.defineMacro("__USING_WASM_EXCEPTIONS__");

sbc100 wrote:

I don't think we should remove the define here, I just want us to consider 
carefully the name of the define if we are going to have the compiler generate 
it.

The removal I was referring to was the `-D...` flags used in emscripten and 
wasi-sdk, which will be redundant once this change land (and they convert to 
using the new macro).

https://github.com/llvm/llvm-project/pull/92604
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Define __WASM_EXCEPTIONS__ for -fwasm-exceptions (PR #92604)

2024-05-17 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 approved this pull request.

lgtm.

@dschuff WDYT?

https://github.com/llvm/llvm-project/pull/92604
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)

2024-05-21 Thread Sam Clegg via cfe-commits

https://github.com/sbc100 approved this pull request.


https://github.com/llvm/llvm-project/pull/92840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)

2024-05-21 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> It is hard to fix the clang-format errors because the modified files 
> generally don't conform to the clang-format style anyway, so clang-format my 
> change currently affects hundreds of unrelated lines.
> 
> ```
> aheejin@aheejin:~/llvm-project/libunwind$ git clang-format main
> changed files:
> libcxxabi/include/cxxabi.h
> libcxxabi/src/cxa_exception.cpp
> libcxxabi/src/cxa_personality.cpp
> 
> aheejin@aheejin:~/llvm-project/libunwind$ git diff --stat
>  libcxxabi/include/cxxabi.h|  13 +-
>  libcxxabi/src/cxa_exception.cpp   |   2 +-
>  libcxxabi/src/cxa_personality.cpp | 256 
> ++--
>  3 files changed, 123 insertions(+), 148 deletions(-)
> ```

I think in these cases is fine to ignore the warnings to fit in with existing 
style.  

https://github.com/llvm/llvm-project/pull/92840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 45ad346 - [clang][WebAssembly] Imply -fno-threadsafe-static when threading is disabled

2022-01-31 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2022-01-31T14:26:09-08:00
New Revision: 45ad3467b708618841869cb529a814001d2295f9

URL: 
https://github.com/llvm/llvm-project/commit/45ad3467b708618841869cb529a814001d2295f9
DIFF: 
https://github.com/llvm/llvm-project/commit/45ad3467b708618841869cb529a814001d2295f9.diff

LOG: [clang][WebAssembly] Imply -fno-threadsafe-static when threading is 
disabled

When we don't enable atomics we completely disabled threading in
which case there is no point in generating thread safe code for
static initialization.

This should always be safe because, in WebAssembly, it is not
possible to link object compiled without the atomics feature into a
mutli-threaded program.

See https://github.com/emscripten-core/emscripten/pull/16152

Differential Revision: https://reviews.llvm.org/D118571

Added: 


Modified: 
clang/lib/Basic/Targets/WebAssembly.cpp
clang/test/CodeGenCXX/static-init-wasm.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 4cba861f61d2c..2309997eb77b2 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -260,6 +260,7 @@ void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags,
   if (!HasAtomics) {
 Opts.POSIXThreads = false;
 Opts.setThreadModel(LangOptions::ThreadModelKind::Single);
+Opts.ThreadsafeStatics = false;
   }
 }
 

diff  --git a/clang/test/CodeGenCXX/static-init-wasm.cpp 
b/clang/test/CodeGenCXX/static-init-wasm.cpp
index 647a61b84721e..0a066de616fa9 100644
--- a/clang/test/CodeGenCXX/static-init-wasm.cpp
+++ b/clang/test/CodeGenCXX/static-init-wasm.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -triple=wasm32-unknown-unknown -o - %s \
+// RUN: %clang_cc1 -emit-llvm -triple=wasm32-unknown-unknown -target-feature 
+atomics -o - %s \
 // RUN:   | FileCheck %s -check-prefix=WEBASSEMBLY32
-// RUN: %clang_cc1 -emit-llvm -triple=wasm64-unknown-unknown -o - %s \
+// RUN: %clang_cc1 -emit-llvm -triple=wasm64-unknown-unknown -target-feature 
+atomics -o - %s \
 // RUN:   | FileCheck %s -check-prefix=WEBASSEMBLY64
 
 // Test that we don't create common blocks.
@@ -52,3 +52,17 @@ A theA;
 // WEBASSEMBLY64: call noundef %struct.A* @_ZN1AC1Ev(%struct.A* {{[^,]*}} 
@theA)
 // WEBASSEMBLY64: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() 
#3 {
 // WEBASSEMBLY64: call void @__cxx_global_var_init()
+
+// RUN: %clang_cc1 -emit-llvm -triple=wasm32-unknown-unknown -o - %s \
+// RUN:   | FileCheck %s -check-prefix=NOATOMICS
+// RUN: %clang_cc1 -emit-llvm -triple=wasm64-unknown-unknown -o - %s \
+// RUN:   | FileCheck %s -check-prefix=NOATOMICS
+
+// NOATOMICS-LABEL: @_Z1gv()
+// NOATOMICS:   %[[R0:.+]] = load i8, i8* @_ZGVZ1gvE1a, align 1
+// NOATOMICS-NEXT:  %guard.uninitialized = icmp eq i8 %[[R0]], 0
+// NOATOMICS-NEXT:  br i1 %guard.uninitialized, label %[[CHECK:.+]], label 
%[[END:.+]],
+// NOATOMICS:   [[CHECK]]:
+// NOATOMICS-NOT:   __cxa_guard_acquire
+// NOATOMICS:   [[END]]:
+// NOATOMICS-NEXT:  ret void



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c832edf - [WebAssembly] Add new target feature in support of 'extended-const' proposal

2022-03-07 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2022-03-07T16:45:42-08:00
New Revision: c832edfd3fbccfac6d5212d6495f0dde851dbdde

URL: 
https://github.com/llvm/llvm-project/commit/c832edfd3fbccfac6d5212d6495f0dde851dbdde
DIFF: 
https://github.com/llvm/llvm-project/commit/c832edfd3fbccfac6d5212d6495f0dde851dbdde.diff

LOG: [WebAssembly] Add new target feature in support of 'extended-const' 
proposal

We don't yet do anything when this feature is enabled, this change
just lays the ground work by accepting that there is such a feature.

See https://github.com/WebAssembly/extended-const

Differential Revision: https://reviews.llvm.org/D121151

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/test/Preprocessor/wasm-target-features.c
llvm/lib/Target/WebAssembly/WebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 77c20d3646500..6815dca1f1529 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3629,6 +3629,8 @@ WebAssembly
 
 .. option:: -mtail-call, -mno-tail-call
 
+.. option:: -mextended-const, -mno-extended-const
+
 WebAssembly Driver
 --
 .. option:: -mexec-model=

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 24e2069711be5..06802ae424f7a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3468,6 +3468,8 @@ def mtail_call : Flag<["-"], "mtail-call">, 
Group;
 def mno_tail_call : Flag<["-"], "mno-tail-call">, Group;
 def mreference_types : Flag<["-"], "mreference-types">, 
Group;
 def mno_reference_types : Flag<["-"], "mno-reference-types">, 
Group;
+def mextended_const : Flag<["-"], "mextended-const">, 
Group;
+def mno_extended_const : Flag<["-"], "mno-extended-const">, 
Group;
 def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group,
  Values<"command,reactor">,
  HelpText<"Execution model (WebAssembly only)">;

diff  --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 18ff109bf2d39..b3b6c2be5c134 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -56,6 +56,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   .Case("multivalue", HasMultivalue)
   .Case("tail-call", HasTailCall)
   .Case("reference-types", HasReferenceTypes)
+  .Case("extended-const", HasExtendedConst)
   .Default(false);
 }
 
@@ -93,6 +94,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
 Builder.defineMacro("__wasm_tail_call__");
   if (HasReferenceTypes)
 Builder.defineMacro("__wasm_reference_types__");
+  if (HasExtendedConst)
+Builder.defineMacro("__wasm_extended_const__");
 }
 
 void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features,
@@ -240,6 +243,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
   HasReferenceTypes = false;
   continue;
 }
+if (Feature == "+extended-const") {
+  HasExtendedConst = true;
+  continue;
+}
+if (Feature == "-extended-const") {
+  HasExtendedConst = false;
+  continue;
+}
 
 Diags.Report(diag::err_opt_not_valid_with_opt)
 << Feature << "-target-feature";

diff  --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index 075486990558b..63418869d10ac 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -39,6 +39,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public 
TargetInfo {
   bool HasMultivalue = false;
   bool HasTailCall = false;
   bool HasReferenceTypes = false;
+  bool HasExtendedConst = false;
 
   std::string ABI;
 

diff  --git a/clang/test/Preprocessor/wasm-target-features.c 
b/clang/test/Preprocessor/wasm-target-features.c
index 3c743142a3e38..c05b26a0c2278 100644
--- a/clang/test/Preprocessor/wasm-target-features.c
+++ b/clang/test/Preprocessor/wasm-target-features.c
@@ -105,6 +105,15 @@
 // RUN:   | FileCheck %s -check-prefix=REFERENCE-TYPES
 //
 // REFERENCE-TYPES:#define __wasm_reference_types__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mextended-const \
+// RUN:   | FileCheck %s -check-prefix=EXTENDED-CONST
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mextended-const \
+// RUN:   | FileCheck %s -check-prefix=EXTENDED-CONST
+//
+// EXTENDED-CONST:#define __wasm_extended_const__ 1{{$}}
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target wasm

[clang] 1813fde - [WebAssembly] Emit clangast in custom section aligned by 4 bytes

2021-10-19 Thread Sam Clegg via cfe-commits

Author: Yuta Saito
Date: 2021-10-19T15:50:08-07:00
New Revision: 1813fde9cc0b56cee42d9b82e6f22fa00a59cdf9

URL: 
https://github.com/llvm/llvm-project/commit/1813fde9cc0b56cee42d9b82e6f22fa00a59cdf9
DIFF: 
https://github.com/llvm/llvm-project/commit/1813fde9cc0b56cee42d9b82e6f22fa00a59cdf9.diff

LOG: [WebAssembly] Emit clangast in custom section aligned by 4 bytes

Emit __clangast in custom section instead of named data segment
to find it while iterating sections.
This could be avoided if all data segements (the wasm sense) were
represented as their own sections (in the llvm sense).
This can be resolved by 
https://github.com/WebAssembly/tool-conventions/issues/138

And the on-disk hashtable in clangast needs to be aligned by 4 bytes,
so add paddings in name length field in custom section header.

The length of clangast section name can be represented in 1 byte
by leb128, and possible maximum pads are 3 bytes, so the section
name length won't be invalid in theory.

Fixes https://bugs.llvm.org/show_bug.cgi?id=35928

Differential Revision: https://reviews.llvm.org/D74531

Added: 
clang/test/PCH/pch-wasm.c
llvm/test/MC/WebAssembly/custom-section-alignment.ll

Modified: 
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
llvm/lib/MC/WasmObjectWriter.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index ce45291af3b82..f7b83c45022d6 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -270,25 +270,42 @@ class PCHContainerGenerator : public ASTConsumer {
 assert(Buffer->IsComplete && "serialization did not complete");
 auto &SerializedAST = Buffer->Data;
 auto Size = SerializedAST.size();
-auto Int8Ty = llvm::Type::getInt8Ty(*VMContext);
-auto *Ty = llvm::ArrayType::get(Int8Ty, Size);
-auto *Data = llvm::ConstantDataArray::getString(
-*VMContext, StringRef(SerializedAST.data(), Size),
-/*AddNull=*/false);
-auto *ASTSym = new llvm::GlobalVariable(
-*M, Ty, /*constant*/ true, llvm::GlobalVariable::InternalLinkage, Data,
-"__clang_ast");
-// The on-disk hashtable needs to be aligned.
-ASTSym->setAlignment(llvm::Align(8));
-
-// Mach-O also needs a segment name.
-if (Triple.isOSBinFormatMachO())
-  ASTSym->setSection("__CLANG,__clangast");
-// COFF has an eight character length limit.
-else if (Triple.isOSBinFormatCOFF())
-  ASTSym->setSection("clangast");
-else
-  ASTSym->setSection("__clangast");
+
+if (Triple.isOSBinFormatWasm()) {
+  // Emit __clangast in custom section instead of named data segment
+  // to find it while iterating sections.
+  // This could be avoided if all data segements (the wasm sense) were
+  // represented as their own sections (in the llvm sense).
+  // TODO: https://github.com/WebAssembly/tool-conventions/issues/138
+  llvm::NamedMDNode *MD =
+  M->getOrInsertNamedMetadata("wasm.custom_sections");
+  llvm::Metadata *Ops[2] = {
+  llvm::MDString::get(*VMContext, "__clangast"),
+  llvm::MDString::get(*VMContext,
+  StringRef(SerializedAST.data(), Size))};
+  auto *NameAndContent = llvm::MDTuple::get(*VMContext, Ops);
+  MD->addOperand(NameAndContent);
+} else {
+  auto Int8Ty = llvm::Type::getInt8Ty(*VMContext);
+  auto *Ty = llvm::ArrayType::get(Int8Ty, Size);
+  auto *Data = llvm::ConstantDataArray::getString(
+  *VMContext, StringRef(SerializedAST.data(), Size),
+  /*AddNull=*/false);
+  auto *ASTSym = new llvm::GlobalVariable(
+  *M, Ty, /*constant*/ true, llvm::GlobalVariable::InternalLinkage,
+  Data, "__clang_ast");
+  // The on-disk hashtable needs to be aligned.
+  ASTSym->setAlignment(llvm::Align(8));
+
+  // Mach-O also needs a segment name.
+  if (Triple.isOSBinFormatMachO())
+ASTSym->setSection("__CLANG,__clangast");
+  // COFF has an eight character length limit.
+  else if (Triple.isOSBinFormatCOFF())
+ASTSym->setSection("clangast");
+  else
+ASTSym->setSection("__clangast");
+}
 
 LLVM_DEBUG({
   // Print the IR for the PCH container to the debug output.

diff  --git a/clang/test/PCH/pch-wasm.c b/clang/test/PCH/pch-wasm.c
new file mode 100644
index 0..c8df80a9fa5fb
--- /dev/null
+++ b/clang/test/PCH/pch-wasm.c
@@ -0,0 +1,7 @@
+// REQUIRES: webassembly-registered-target
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown-wasm -emit-pch 
-fmodule-format=obj %S/pchpch1.h -o - | llvm-objdump --section-headers - | 
FileCheck %s
+
+// Ensure that clangast section should be emitted in a section for wasm object 
file
+
+// CHECK: file format wasm
+// CHECK: __clangast   {{[0-9a-f]+}} {{[0-9a-f

[clang] c05d30e - [clang][Emscripten] Define __unix family of macros

2021-08-25 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2021-08-25T19:24:47-04:00
New Revision: c05d30e444a1208a8a872002d1146b5cf55e370a

URL: 
https://github.com/llvm/llvm-project/commit/c05d30e444a1208a8a872002d1146b5cf55e370a
DIFF: 
https://github.com/llvm/llvm-project/commit/c05d30e444a1208a8a872002d1146b5cf55e370a.diff

LOG: [clang][Emscripten] Define __unix family of macros

This will allow us to remove these from the downstream
driver:
https://github.com/emscripten-core/emscripten/blob/57270ce8150a5107e591b4e9ec7cbeff0ba7c905/emcc.py#L860-L863

Differential Revision: https://reviews.llvm.org/D108735

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 440ec63f9cef0..e9dcc9e84dd7c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -944,6 +944,7 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
   void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
 MacroBuilder &Builder) const final {
 WebAssemblyOSTargetInfo::getOSDefines(Opts, Triple, Builder);
+DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__EMSCRIPTEN__");
 if (Opts.POSIXThreads)
   Builder.defineMacro("__EMSCRIPTEN_PTHREADS__");

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 65d737352cad0..c14ef173390a9 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1847,8 +1847,10 @@
 // WEBASSEMBLY-NEXT:#define __clang_version__ "{{.*}}"
 // WEBASSEMBLY-NEXT:#define __clang_wide_literal_encoding__ {{.*}}
 // WEBASSEMBLY-NEXT:#define __llvm__ 1
-// WEBASSEMBLY-NOT:#define __unix
-// WEBASSEMBLY-NOT:#define __unix__
+// WEBASSEMBLY-WASI-NOT:#define __unix
+// WEBASSEMBLY-WASI-NOT:#define __unix__
+// EMSCRIPTEN-NEXT:#define __unix 1
+// EMSCRIPTEN-NEXT:#define __unix__ 1
 // WEBASSEMBLY-WASI-NEXT:#define __wasi__ 1
 // WEBASSEMBLY-NOT:#define __wasm_simd128__
 // WEBASSEMBLY-NOT:#define __wasm_simd256__
@@ -1863,6 +1865,8 @@
 // WEBASSEMBLY64-NEXT:#define __wasm64 1
 // WEBASSEMBLY64-NEXT:#define __wasm64__ 1
 // WEBASSEMBLY-NEXT:#define __wasm__ 1
+// EMSCRIPTEN:#define unix 1
+// WEBASSEMBLY-WASI-NOT:#define unix 1
 // WEBASSEMBLY-CXX-NOT:_REENTRANT
 // WEBASSEMBLY-CXX-NOT:__STDCPP_THREADS__
 // WEBASSEMBLY-CXX-ATOMICS:#define _REENTRANT 1



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add flag to opt out of wasm-opt (PR #95208)

2024-06-24 Thread Sam Clegg via cfe-commits

sbc100 wrote:

I wonder if there is some why to avoiding adding this new option globally like 
this and instead limit it in scope the wasm target in some way? 



https://github.com/llvm/llvm-project/pull/95208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] [WebAssembly] Enable nontrapping-fptoint and bulk-memory by default. (PR #112049)

2024-10-14 Thread Sam Clegg via cfe-commits


@@ -2,7 +2,7 @@
 ; RUN: llvm-as -o %t.o %s
 ; RUN: llvm-as -o %t2.o %S/Inputs/libcall-archive.ll
 ; RUN: llvm-ar rcs %t.a %t2.o
-; RUN: wasm-ld -o %t %t.o %t.a
+; RUN: wasm-ld -mllvm -mattr=-bulk-memory -o %t %t.o %t.a

sbc100 wrote:

Why is this needed?  Should this come from the object file if it needs it?

https://github.com/llvm/llvm-project/pull/112049
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >