Permalink
Browse files

Only run tests/baremetal/wasm[2].d if wasm can be linked

I.e., if -link-internally is available (if so, it will usually be used
automatically for wasm targets via extra default switch in wasm section
of ldc2.conf - unless disabling the config file via `-conf=`, as done
for tests/baremetal/wasm.d), or if an external `wasm-ld` linker is found
in PATH.
  • Loading branch information...
kinke committed Dec 23, 2018
1 parent c7b1736 commit 794907b9988968ef6cd89a1683364ec37eb44686
Showing with 16 additions and 2 deletions.
  1. +12 −0 tests/baremetal/lit.local.cfg
  2. +2 −1 tests/baremetal/wasm.d
  3. +1 −0 tests/baremetal/wasm2.d
  4. +1 −1 tests/lit.site.cfg.in
@@ -1,4 +1,16 @@
import subprocess

# Define `%baremetal_args` as LDC args making sure
# * no ldc2.conf file is used (=> no implicit command-line args), and
# * the empty object.d in ./inputs is imported (=> no TypeInfo, ModuleInfo, Object...).
config.substitutions.append( ('%baremetal_args', '-conf= -I' + config.test_source_root + '/baremetal/inputs') )

# Add "link_WebAssembly" feature if we can link wasm (-link-internally or wasm-ld in PATH).
if config.ldc_with_lld:
config.available_features.add('link_WebAssembly')
else:
try:
if (subprocess.call(["wasm-ld", "--version"]) == 0):
config.available_features.add('link_WebAssembly')
except OSError:
pass
@@ -1,7 +1,8 @@
// Compile and link directly to WebAssembly.

// REQUIRES: target_WebAssembly
// RUN: %ldc -mtriple=wasm32-unknown-unknown-wasm %s %baremetal_args
// REQUIRES: internal_lld
// RUN: %ldc -mtriple=wasm32-unknown-unknown-wasm -link-internally %s %baremetal_args

extern(C): // no mangling, no arguments order reversal

@@ -1,6 +1,7 @@
// A more complex wasm example using Phobos templates (=> -betterC to keep it simple).

// REQUIRES: target_WebAssembly
// REQUIRES: link_WebAssembly
// RUN: %ldc -mtriple=wasm32-unknown-unknown-wasm -betterC %s

extern(C):
@@ -25,7 +25,7 @@ config.dynamic_compile = @LDC_DYNAMIC_COMPILE@
config.plugins_supported = "@LDC_ENABLE_PLUGINS@" == "ON"
config.gnu_make_bin = "@GNU_MAKE_BIN@"
config.ldc_host_arch = "@LDC_HOST_ARCH@"
config.ldc_with_lld = "@LDC_WITH_LLD@"
config.ldc_with_lld = "@LDC_WITH_LLD@" == "ON"

config.name = 'LDC'

0 comments on commit 794907b

Please sign in to comment.