Skip to content

Commit 13c9935

Browse files
authored
Pass llvm opts when compiling .ll files. (#15486)
I broke this in #12705 when I started treating `.ll` files like `.s` files and not passing any c flags (or llvm flags). Fixes: #15370
1 parent ad17782 commit 13c9935

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

emcc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,15 @@
6060
CXX_ENDINGS = ('.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.C', '.CC', '.C++', '.ii')
6161
OBJC_ENDINGS = ('.m', '.mi')
6262
OBJCXX_ENDINGS = ('.mm', '.mii')
63-
ASSEMBLY_CPP_ENDINGS = ('.S',)
6463
SPECIAL_ENDINGLESS_FILENAMES = (os.devnull,)
6564

66-
SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + OBJC_ENDINGS + OBJCXX_ENDINGS + SPECIAL_ENDINGLESS_FILENAMES + ASSEMBLY_CPP_ENDINGS
65+
SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + OBJC_ENDINGS + OBJCXX_ENDINGS + SPECIAL_ENDINGLESS_FILENAMES + ('.ll', '.S')
6766
C_ENDINGS = C_ENDINGS + SPECIAL_ENDINGLESS_FILENAMES # consider the special endingless filenames like /dev/null to be C
6867

6968
EXECUTABLE_ENDINGS = ('.wasm', '.html', '.js', '.mjs', '.out', '')
7069
DYNAMICLIB_ENDINGS = ('.dylib', '.so') # Windows .dll suffix is not included in this list, since those are never linked to directly on the command line.
7170
STATICLIB_ENDINGS = ('.a',)
72-
ASSEMBLY_ENDINGS = ('.ll', '.s')
71+
ASSEMBLY_ENDINGS = ('.s',)
7372
HEADER_ENDINGS = ('.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH')
7473

7574
# Supported LLD flags which we will pass through to the linker.

tests/test_other.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4337,6 +4337,14 @@ def test_emit_llvm(self):
43374337
self.run_process([EMCC, test_file('hello_world.c'), '-c', '-emit-llvm'])
43384338
self.assertTrue(building.is_bitcode('hello_world.bc'))
43394339

4340+
def test_compile_ll_file(self):
4341+
self.run_process([EMCC, test_file('hello_world.c'), '-S', '-emit-llvm'])
4342+
err = self.run_process([EMCC, '-v', '-c', 'hello_world.ll', '-o', 'hello_world.o'], stderr=PIPE).stderr
4343+
# Verify that `-mllvm` flags are passed when compiling `.ll` files.
4344+
self.assertContained('-mllvm -enable-emscripten-sjlj', err)
4345+
self.run_process([EMCC, 'hello_world.o'])
4346+
self.assertContained('hello, world!', self.run_js('a.out.js'))
4347+
43404348
def test_dashE(self):
43414349
create_file('src.cpp', r'''#include <emscripten.h>
43424350
__EMSCRIPTEN_major__ __EMSCRIPTEN_minor__ __EMSCRIPTEN_tiny__ EMSCRIPTEN_KEEPALIVE

0 commit comments

Comments
 (0)