summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains/WebAssembly.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Default to -fuse-init-arrayFangrui Song2019-12-121-3/+3
| | | | | | | | | | | | | | | | | | | Very few ELF platforms still use .ctors/.dtors now. Linux (glibc: 1999-07), DragonFlyBSD, FreeBSD (2012-03) and Solaris have supported .init_array for many years. Some architectures like AArch64/RISC-V default to .init_array . GNU ld and gold can even convert .ctors to .init_array . It makes more sense to flip the CC1 default, and only uses -fno-use-init-array on platforms that don't support .init_array . For example, OpenBSD did not support DT_INIT_ARRAY before Aug 2016 (https://github.com/openbsd/src/commit/86fa57a2792c6374b0849dd7b818a11e676e60ba) I may miss some ELF platforms that still use .ctors, but their maintainers can easily diagnose such problems. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D71393
* [WebAssembly] Find wasm-opt with GetProgramPathDan Gohman2019-12-021-4/+4
| | | | | | | Instead of just searching for wasm-opt in PATH, use GetProgramPath, which checks the `COMPILER_PATH` environment variable, -B paths, and `PATH`. Differential Revision: https://reviews.llvm.org/D70780
* [WebAssembly] Change the llvm-lto dir to use the LLVM VersionDan Gohman2019-11-251-11/+17
| | | | | | | | | Using the version instead of the VCS revision, which isn't available when LLVM_APPEND_VC_REV is set. The bitcode format should be backwards-compatible at least within a minor version, so the version string should be sufficient. Differential Revision: https://reviews.llvm.org/D70677
* [WebAssembly] Use wasm-opt and LTO libraries when available.Dan Gohman2019-11-221-0/+36
| | | | | | | | | | When there's a wasm-opt in the PATH, run the it to optimize LLVM's output. This fixes PR43796. And, add an "llvm-lto" directory to the sysroot library search paths, so that sysroots can provide LTO-enabled system libraries. Differential Revision: https://reviews.llvm.org/D70500
* [WebAssembly] -fwasm-exceptions enables reference-typesHeejin Ahn2019-11-131-1/+9
| | | | | | | | | | | | | | | Summary: This adds `-mreference-types` and `-mno-reference-types` flags to clang and make `-fwasm-exceptions` enables reference types feature in clang and the backend. Reviewers: tlively Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69832
* [WebAssembly] -pthread implies -target-feature +sign-extThomas Lively2019-10-181-1/+8
| | | | | | | | | | | | | | | | | Summary: The sign extension proposal was motivated by a desire to not have separate sign-extending atomic operations, so it is meant to be enabled when threads are used. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69075 llvm-svn: 375199
* [WebAssembly] Add -fwasm-exceptions for wasm EHHeejin Ahn2019-09-121-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This adds `-fwasm-exceptions` (in similar fashion with `-fdwarf-exceptions` or `-fsjlj-exceptions`) that turns on everything with wasm exception handling from the frontend to the backend. We currently have `-mexception-handling` in clang frontend, but this is only about the architecture capability and does not turn on other necessary options such as the exception model in the backend. (This can be turned on with `llc -exception-model=wasm`, but llc is not invoked separately as a command line tool, so this option has to be transferred from clang.) Turning on `-fwasm-exceptions` in clang also turns on `-mexception-handling` if not specified, and will error out if `-mno-exception-handling` is specified. Reviewers: dschuff, tlively, sbc100 Subscribers: aprantl, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67208 llvm-svn: 371708
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-1/+1
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
* [WebAssembly] Make pthread imply bulk-memory, mutable-globalsThomas Lively2019-07-121-1/+15
| | | | | | | | | | | | | | | | | Summary: This paves the way for using passive segments in pthread builds, which will make separate memory files unnecessary. Mutable globals are also necessary for the upcoming implementation of TLS. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64586 llvm-svn: 365935
* [WebAssembly] Implement Address Sanitizer for EmscriptenGuanzhong Chen2019-06-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: This diff enables address sanitizer on Emscripten. On Emscripten, real memory starts at the value passed to --global-base. All memory before this is used as shadow memory, and thus the shadow mapping function is simply dividing by 8. Reviewers: tlively, aheejin, sbc100 Reviewed By: sbc100 Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63742 llvm-svn: 364468
* [WebAssembly] Modernize include path handlingSam Clegg2019-06-131-7/+34
| | | | | | | | | | 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 llvm-svn: 363241
* [WebAssembly] Support Leak Sanitizer on EmscriptenThomas Lively2019-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | Summary: LSan is currently being ported to Emscripten and mostly works. Enabling the support in upstream would simplify testing. Patch by Guanzhong Chen. Reviewers: tlively, aheejin Reviewed By: aheejin Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62830 llvm-svn: 362667
* [WebAssembly] Support VPtr sanitizer for EmscriptenThomas Lively2019-05-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | Summary: After https://github.com/emscripten-core/emscripten/pull/8651, Emscripten supports the full UBSan runtime. This includes the VPtr sanitizer. This diff allows clang to generate code that uses the VPtr sanitizer for Emscripten. Patch by Guanzhong Chen Reviewers: tlively, aheejin Reviewed By: aheejin Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62559 llvm-svn: 362004
* [WebAssembly] Use "linker" as linker shortname.Sam Clegg2019-05-241-7/+0
| | | | | | | | | | | 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 llvm-svn: 361651
* [WebAssembly] Reland of rL356953 (4dcf3acce6)Sam Clegg2019-03-281-1/+22
| | | | | | | | | The previous patch was missing GetProgramPath() in the return value of getLinkerPath(). See https://reviews.llvm.org/D59743 llvm-svn: 357195
* Revert "[WebAssembly] Don't use default GetLinkerPath"Derek Schuff2019-03-271-22/+1
| | | | | | | This reverts commit 4dcf3acce6d7455fd079d8e57441906ca2bad254. (reverts LLVM SVN r356953) llvm-svn: 357127
* [WebAssembly] Don't use default GetLinkerPathSam Clegg2019-03-251-1/+22
| | | | | | | | | | | | | | | | | 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 llvm-svn: 356953
* [WebAssembly] Make driver -pthread imply linker --shared-memoryThomas Lively2019-03-221-1/+3
| | | | | | | | | | | | | | | | Summary: This eliminates a linker error the user might otherwise see about how using the 'atomics' feature requires --shared-memory. Reviewers: sbc100, aheejin Subscribers: dschuff, jgravelle-google, sunfish, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59721 llvm-svn: 356817
* [WebAssembly] Temporarily disable bulk-memory with -pthreadThomas Lively2019-03-021-21/+1
| | | | | | | | | | | | | | | | | | | Summary: To prevent the instability of bulk-memory in the wasm backend from blocking separate pthread testing, temporarily remove the logic that adds -mbulk-memory in the presence of -pthread. Since browsers will ship bulk memory before or alongside threads, this change will be reverted as soon as bulk memory has stabilized in the backend. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, aheejin, sunfish, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58854 llvm-svn: 355248
* [WebAssembly] Remove uses of ThreadModelThomas Lively2019-02-281-39/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In the clang UI, replaces -mthread-model posix with -matomics as the source of truth on threading. In the backend, replaces -thread-model=posix with the atomics target feature, which is now collected on the WebAssemblyTargetMachine along with all other used features. These collected features will also be used to emit the target features section in the future. The default configuration for the backend is thread-model=posix and no atomics, which was previously an invalid configuration. This change makes the default valid because the thread model is ignored. A side effect of this change is that objects are never emitted with passive segments. It will instead be up to the linker to decide whether sections should be active or passive based on whether atomics are used in the final link. Reviewers: aheejin, sbc100, dschuff Subscribers: mehdi_amini, jgravelle-google, hiraditya, sunfish, steven_wu, dexonsmith, rupprecht, jfb, jdoerfert, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D58742 llvm-svn: 355112
* [WebAssembly] Make thread-related options consistentHeejin Ahn2019-02-111-6/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There have been three options related to threads and users had to set all three of them separately to get the correct compilation results. This makes sure the relationship between the options makes sense and sets necessary options for users if only part of the necessary options are specified. This does: - Remove `-matomics`; this option alone does not enable anything, so removed it to not confuse users. - `-mthread-model posix` sets `-target-feature +atomics` - `-pthread` sets both `-target-feature +atomics` and `-mthread-model posix` Also errors out when explicitly given options don't match, such as `-pthread` is given with `-mthread-model single`. Reviewers: dschuff, sbc100, tlively, sunfish Subscribers: jgravelle-google, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57874 llvm-svn: 353761
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [WebAssembly] Support multilibs for wasm32 and add a wasm OS that uses itDan Gohman2019-01-151-3/+35
| | | | | | | | | | | | This adds support for multilib paths for wasm32 targets, following [Debian's Multiarch conventions], and also adds an experimental OS name in order to test it. [Debian's Multiarch conventions]: https://wiki.debian.org/Multiarch/ Differential Revision: https://reviews.llvm.org/D56553 llvm-svn: 351164
* [WebAssembly] clang-format (NFC)Heejin Ahn2018-08-311-9/+6
| | | | | | | | | | Summary: This patch runs clang-format on all wasm-only files. Subscribers: dschuff, sbc100, jgravelle-google, sunfish, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D51448 llvm-svn: 341254
* [WebAssembly] Remove use of lld -flavor flagSam Clegg2018-08-071-2/+0
| | | | | | | | | 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 llvm-svn: 339163
* [WebAssembly] Support -stdlib=libc++ switchSam Clegg2018-01-121-0/+20
| | | | | | | | | | | | | | 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 llvm-svn: 322382
* [WebAssembly] Remove `-allow-undefined-file wasm.syms` from linker argsSam Clegg2018-01-111-2/+0
| | | | | | | | See: https://github.com/WebAssembly/tool-conventions/issues/35 Differential Revision: https://reviews.llvm.org/D41923 llvm-svn: 322321
* [WebAssembly] Pass through --undefined to Wasm LLDSam Clegg2017-12-021-0/+1
| | | | | | | | | | | 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 llvm-svn: 319623
* [WebAssemby] Enable "-mthread-model single" by default, for now.Dan Gohman2017-11-271-0/+8
| | | | | | | | | | | | | The WebAssembly standard does not yet have threads, and while it's in the process of being standardized, it'll take some time for it to make it through and be available in all popular implementations. With increasing numbers of people using the LLVM wasm backend through LLVM directly rather than through Emscripten, it's increasingly important to have friendly defaults. See also https://bugs.llvm.org/show_bug.cgi?id=35411 llvm-svn: 319101
* Driver: remove `SupportsObjCGC` (NFC)Saleem Abdulrasool2017-11-191-3/+0
| | | | | | This option is not used in the frontend. Remove the method. llvm-svn: 318609
* [WebAssembly] Add crt1.o with calling lldSam Clegg2017-10-271-0/+3
| | | | | | | | | 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 llvm-svn: 316777
* [WebAssembly] Include libclang_rt.builtins in the standard waySam Clegg2017-10-271-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D39218 llvm-svn: 316719
* [WebAssembly] Remove invliad lld argumentsSam Clegg2017-09-141-27/+0
| | | | | | | | | | | 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 llvm-svn: 313299
* Introduce -nostdlib++ flag to disable linking the C++ standard library.Nico Weber2017-07-251-2/+1
| | | | | | | | | | | | | | | Projects that want to statically link their own C++ standard library currently need to pass -nostdlib or -nodefaultlibs, which also disables linking of the builtins library, -lm, and so on. Alternatively, they could use `clang` instead of `clang++`, but that already disables implicit addition of -lm on some toolchains. Add a dedicated flag -nostdlib++ that disables just linking of libc++ / libstdc++. This is analogous to -nostdinc++. https://reviews.llvm.org/D35780 llvm-svn: 308997
* [OpenMP] Extend CLANG target options with device offloading kind.Gheorghe-Teodor Bercea2017-07-061-1/+2
| | | | | | | | | | | | | | Summary: Pass the type of the device offloading when building the tool chain for a particular target architecture. This is required when supporting multiple tool chains that target a single device type. In our particular use case, the OpenMP and CUDA tool chains will use the same ```addClangTargetOptions ``` method. This enables the reuse of common options and ensures control over options only supported by a particular tool chain. Reviewers: arpith-jacob, caomhin, carlo.bertolli, ABataev, jlebar, hfinkel, tstellar, Hahnfeld Reviewed By: hfinkel Subscribers: jgravelle-google, aheejin, rengolin, jfb, dschuff, sbc100, cfe-commits Differential Revision: https://reviews.llvm.org/D29647 llvm-svn: 307272
* [WebAssembly] Add default -allow-undefined-file to linker argsSam Clegg2017-06-231-2/+3
| | | | | | | | | | | 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/<target-tripple> and /include/<target-tripple>. Differential Revision: https://reviews.llvm.org/D33565 llvm-svn: 306074
* [WebAssembly] Fix location and -flavor when running lldSam Clegg2017-05-091-1/+4
| | | | | | | | | | | | | 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 llvm-svn: 302558
* [Driver] Consolidate tools and toolchains by target platform. (NFC)David L. Jones2017-03-081-0/+163
Summary: (This is a move-only refactoring patch. There are no functionality changes.) This patch splits apart the Clang driver's tool and toolchain implementation files. Each target platform toolchain is moved to its own file, along with the closest-related tools. Each target platform toolchain has separate headers and implementation files, so the hierarchy of classes is unchanged. There are some remaining shared free functions, mostly from Tools.cpp. Several of these move to their own architecture-specific files, similar to r296056. Some of them are only used by a single target platform; since the tools and toolchains are now together, some helpers now live in a platform-specific file. The balance are helpers related to manipulating argument lists, so they are now in a new file pair, CommonArgs.h and .cpp. I've tried to cluster the code logically, which is fairly straightforward for most of the target platforms and shared architectures. I think I've made reasonable choices for these, as well as the various shared helpers; but of course, I'm happy to hear feedback in the review. There are some particular things I don't like about this patch, but haven't been able to find a better overall solution. The first is the proliferation of files: there are several files that are tiny because the toolchain is not very different from its base (usually the Gnu tools/toolchain). I think this is mostly a reflection of the true complexity, though, so it may not be "fixable" in any reasonable sense. The second thing I don't like are the includes like "../Something.h". I've avoided this largely by clustering into the current file structure. However, a few of these includes remain, and in those cases it doesn't make sense to me to sink an existing file any deeper. Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D30372 llvm-svn: 297250
OpenPOWER on IntegriCloud