Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions scripts/test/generate_lld_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ def generate_wat_files(llvm_bin, emscripten_sysroot):
is_64 = '64' in src_file

compile_cmd = [
os.path.join(llvm_bin, 'clang'), src_path, '-o', obj_path,
os.path.join(llvm_bin, 'clang'), '-c', src_path, '-o', obj_path,
'-mllvm', '-enable-emscripten-sjlj',
'-c',
'-nostdinc',
'-Xclang', '-nobuiltininc',
'-Xclang', '-nostdsysteminc',
'-Xclang', f'-I{emscripten_sysroot}/include'
'--sysroot', emscripten_sysroot,
'-O1',
]

Expand All @@ -68,7 +64,6 @@ def generate_wat_files(llvm_bin, emscripten_sysroot):
'--export', '__wasm_call_ctors',
'--export', '__start_em_asm',
'--export', '__stop_em_asm',
'--global-base=568',
]
# We had a regression where this test only worked if debug names
# were included.
Expand All @@ -79,10 +74,13 @@ def generate_wat_files(llvm_bin, emscripten_sysroot):
compile_cmd.append('-fvisibility=default')
link_cmd.append('-shared')
link_cmd.append('--experimental-pic')
elif 'reserved_func_ptr' in src_file:
link_cmd.append('--entry=__main_argc_argv')
else:
link_cmd.append('--entry=main')
link_cmd.append('--global-base=568')
link_cmd.append('--no-stack-first')
if 'reserved_func_ptr' in src_file:
link_cmd.append('--entry=__main_argc_argv')
else:
link_cmd.append('--entry=main')

if is_64:
compile_cmd.append('--target=wasm64-emscripten')
Expand Down
8 changes: 4 additions & 4 deletions test/lld/basic_safe_stack.wat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(type $i32_=>_none (func (param i32)))
(type $i32_=>_i32 (func (param i32) (result i32)))
(module $basic_safe_stack.wasm
(type $0 (func))
(type $1 (func (param i32)))
(type $2 (func (param i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66112))
(memory $0 2)
(export "memory" (memory $0))
Expand Down
8 changes: 4 additions & 4 deletions test/lld/basic_safe_stack.wat.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(type $i32_=>_none (func (param i32)))
(type $i32_=>_i32 (func (param i32) (result i32)))
(module $basic_safe_stack.wasm
(type $0 (func))
(type $1 (func (param i32)))
(type $2 (func (param i32) (result i32)))
(type $3 (func (param i32 i32)))
(import "env" "__handle_stack_overflow" (func $__handle_stack_overflow (param i32)))
(global $__stack_pointer (mut i32) (i32.const 66112))
Expand Down
13 changes: 7 additions & 6 deletions test/lld/em_asm.wat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $em_asm.wasm
(type $0 (func (param i32 i32 i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66208))
(global $global$1 i32 (i32.const 574))
Expand Down Expand Up @@ -68,6 +68,7 @@
(func $main (param $0 i32) (param $1 i32) (result i32)
(call $__original_main)
)
;; custom section "producers", size 112
;; custom section "producers", size 115
;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, reference-types, multivalue, bulk-memory-opt, call-indirect-overlong
)

10 changes: 5 additions & 5 deletions test/lld/em_asm.wat.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $em_asm.wasm
(type $0 (func (param i32 i32 i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66208))
(global $global$1 i32 (i32.const 574))
Expand Down
16 changes: 8 additions & 8 deletions test/lld/em_asm64.wat
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(module
(type $i64_i64_i64_=>_i32 (func (param i64 i64 i64) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i64_=>_i32 (func (param i32 i64) (result i32)))
(module $em_asm64.wasm
(type $0 (func (param i64 i64 i64) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i64) (result i32)))
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i64 i64 i64) (result i32)))
(global $__stack_pointer (mut i64) (i64.const 66208))
(global $global$1 i64 (i64.const 574))
(global $global$2 i64 (i64.const 658))
(memory $0 i64 2)
(data $.rodata (i64.const 568) "\00ii\00i\00")
(data $em_asm (i64.const 574) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00")
(table $0 1 1 funcref)
(table $0 i64 1 1 funcref)
(export "memory" (memory $0))
(export "__wasm_call_ctors" (func $__wasm_call_ctors))
(export "main" (func $main))
Expand Down Expand Up @@ -68,7 +68,7 @@
(func $main (param $0 i32) (param $1 i64) (result i32)
(call $__original_main)
)
;; custom section "producers", size 112
;; features section: memory64
;; custom section "producers", size 115
;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, reference-types, multivalue, memory64, bulk-memory-opt, call-indirect-overlong
)

12 changes: 6 additions & 6 deletions test/lld/em_asm64.wat.out
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(module
(type $i64_i64_i64_=>_i32 (func (param i64 i64 i64) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i64_=>_i32 (func (param i32 i64) (result i32)))
(module $em_asm64.wasm
(type $0 (func (param i64 i64 i64) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i64) (result i32)))
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i64 i64 i64) (result i32)))
(global $__stack_pointer (mut i64) (i64.const 66208))
(global $global$1 i64 (i64.const 574))
(global $global$2 i64 (i64.const 658))
(memory $0 i64 2)
(data $.rodata (i64.const 568) "\00ii\00i\00")
(data $em_asm (i64.const 574) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00")
(table $0 1 1 funcref)
(table $0 i64 1 1 funcref)
(export "memory" (memory $0))
(export "__wasm_call_ctors" (func $__wasm_call_ctors))
(export "main" (func $main))
Expand Down
13 changes: 7 additions & 6 deletions test/lld/em_asm_O0.wat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $em_asm_O0.wasm
(type $0 (func (param i32 i32 i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66192))
(global $global$1 i32 (i32.const 568))
Expand Down Expand Up @@ -96,6 +96,7 @@
(func $main (param $0 i32) (param $1 i32) (result i32)
(call $__original_main)
)
;; custom section "producers", size 112
;; custom section "producers", size 115
;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, reference-types, multivalue, bulk-memory-opt, call-indirect-overlong
)

10 changes: 5 additions & 5 deletions test/lld/em_asm_O0.wat.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $em_asm_O0.wasm
(type $0 (func (param i32 i32 i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66192))
(global $global$1 i32 (i32.const 568))
Expand Down
17 changes: 7 additions & 10 deletions test/lld/em_asm_shared.wat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $none_=>_none (func))
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $em_asm_shared.wasm
(type $0 (func (param i32 i32 i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "memory" (memory $mimport$0 1))
(import "env" "__indirect_function_table" (table $timport$0 0 funcref))
(import "env" "__stack_pointer" (global $__stack_pointer (mut i32)))
Expand All @@ -19,7 +19,6 @@
(global $global$4 i32 (i32.const 90))
(data $.data (global.get $__memory_base) "\00ii\00i\00{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00")
(export "__wasm_call_ctors" (func $__wasm_call_ctors))
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
(export "__original_main" (func $__original_main))
(export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $global$0))
(export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" (global $global$1))
Expand All @@ -29,8 +28,6 @@
(export "__stop_em_asm" (global $global$4))
(func $__wasm_call_ctors
)
(func $__wasm_apply_data_relocs
)
(func $__original_main (result i32)
(local $0 i32)
(local $1 i32)
Expand Down Expand Up @@ -98,7 +95,7 @@
;; memoryalignment: 0
;; tablesize: 0
;; tablealignment: 0
;; custom section "producers", size 112
;; features section: mutable-globals
;; custom section "producers", size 115
;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, reference-types, multivalue, bulk-memory-opt, call-indirect-overlong
)

13 changes: 5 additions & 8 deletions test/lld/em_asm_shared.wat.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $none_=>_none (func))
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $em_asm_shared.wasm
(type $0 (func (param i32 i32 i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "memory" (memory $mimport$0 1))
(import "env" "__indirect_function_table" (table $timport$0 0 funcref))
(import "env" "__stack_pointer" (global $__stack_pointer (mut i32)))
Expand All @@ -19,7 +19,6 @@
(global $global$4 i32 (i32.const 90))
(data $.data (global.get $__memory_base) "\00ii\00i\00{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00")
(export "__wasm_call_ctors" (func $__wasm_call_ctors))
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
(export "__original_main" (func $__original_main))
(export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJEEE6bufferE" (global $global$0))
(export "_ZN20__em_asm_sig_builderI19__em_asm_type_tupleIJiiEEE6bufferE" (global $global$1))
Expand All @@ -29,8 +28,6 @@
(export "__stop_em_asm" (global $global$4))
(func $__wasm_call_ctors
)
(func $__wasm_apply_data_relocs
)
(func $__original_main (result i32)
(local $0 i32)
(local $1 i32)
Expand Down
13 changes: 7 additions & 6 deletions test/lld/hello_world.wat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $hello_world.wasm
(type $0 (func (param i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "puts" (func $puts (param i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66128))
(memory $0 2)
Expand All @@ -24,6 +24,7 @@
(func $main (param $0 i32) (param $1 i32) (result i32)
(call $__original_main)
)
;; custom section "producers", size 112
;; custom section "producers", size 115
;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, reference-types, multivalue, bulk-memory-opt, call-indirect-overlong
)

10 changes: 5 additions & 5 deletions test/lld/hello_world.wat.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $hello_world.wasm
(type $0 (func (param i32) (result i32)))
(type $1 (func))
(type $2 (func (result i32)))
(type $3 (func (param i32 i32) (result i32)))
(import "env" "puts" (func $puts (param i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66128))
(memory $0 2)
Expand Down
11 changes: 6 additions & 5 deletions test/lld/init.wat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $init.wasm
(type $0 (func))
(type $1 (func (result i32)))
(type $2 (func (param i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66112))
(memory $0 2)
(table $0 1 1 funcref)
Expand Down Expand Up @@ -37,6 +37,7 @@
(func $main (param $0 i32) (param $1 i32) (result i32)
(call $__original_main)
)
;; custom section "producers", size 112
;; custom section "producers", size 115
;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, reference-types, multivalue, bulk-memory-opt, call-indirect-overlong
)

8 changes: 4 additions & 4 deletions test/lld/init.wat.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(module $init.wasm
(type $0 (func))
(type $1 (func (result i32)))
(type $2 (func (param i32 i32) (result i32)))
(global $__stack_pointer (mut i32) (i32.const 66112))
(memory $0 2)
(table $0 1 1 funcref)
Expand Down
Loading
Loading