Skip to content

Commit

Permalink
Fix sil-func-extractor and driver (#28)
Browse files Browse the repository at this point in the history
* [WASM] Remove rpath flag and link objects using llvm-ar instead of ar

* [WASM] Disable objc interop for sil-func-extractor when targeting wasm

* [WASM] Exclude test cases which use -enable-objc-interop

* [WASM] Make availability_returns_twice.swift unsupoorted on wasi due to lack of setjmp
  • Loading branch information
kateinoigakukun committed Jan 11, 2020
1 parent a2bb344 commit b335c43
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/Driver/UnixToolChains.cpp
Expand Up @@ -346,7 +346,12 @@ toolchains::GenericUnix::constructInvocation(const StaticLinkJobAction &job,
ArgStringList Arguments;

// Configure the toolchain.
const char *AR = "ar";
const char *AR;
if (getTriple().isOSBinFormatWasm()) {
AR = "llvm-ar";
} else {
AR = "ar";
}
Arguments.push_back("crs");

Arguments.push_back(
Expand Down
1 change: 1 addition & 0 deletions test/ClangImporter/availability_returns_twice.swift
@@ -1,5 +1,6 @@
// RUN: %target-typecheck-verify-swift
// UNSUPPORTED: OS=windows-msvc
// UNSUPPORTED: OS=wasi
// In Android jmp_buf is int[16], which doesn't convert to &Int (SR-9136)
// XFAIL: OS=linux-androideabi
// XFAIL: OS=linux-android
Expand Down
24 changes: 22 additions & 2 deletions test/lit.cfg
Expand Up @@ -1253,10 +1253,30 @@ elif run_os == 'wasi':

config.target_object_format = "wasm"
config.target_shared_library_prefix = 'lib'
config.target_shared_library_suffix = ".so"
config.target_shared_library_suffix = ".a"
config.target_sdk_name = "wasi"
config.target_runtime = "native"

# Exclude test cases that use objc-interop because clang doesn't support it
# with WebAssembly binary file yet.
testfiles = glob.glob(os.path.join(config.test_source_root, "**", "*.swift"))

def use_objc_interop(path):
with open(path) as f:
return '-enable-objc-interop' in f.read()

import fnmatch
def objc_interop_enabled_filenames(path, filename_pat):
matches = []
for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, filename_pat):
filepath = os.path.join(root, filename)
if not use_objc_interop(filepath): continue
matches.append(filename)
return matches

config.excludes += objc_interop_enabled_filenames(config.test_source_root, "*.swift")

config.target_swift_autolink_extract = inferSwiftBinary("swift-autolink-extract")

config.target_build_swift = ' '.join([
Expand All @@ -1273,7 +1293,7 @@ elif run_os == 'wasi':
config.target_build_swift_dylib = (
"%s -parse-as-library -emit-library -o '\\1'"
% (config.target_build_swift))
config.target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
config.target_add_rpath = ''
config.target_swift_frontend = (
'%s -frontend -target %s %s %s %s %s '
% (config.swift, config.variant_triple, resource_dir_opt, mcp_opt,
Expand Down
2 changes: 2 additions & 0 deletions tools/sil-func-extractor/SILFunctionExtractor.cpp
Expand Up @@ -249,6 +249,8 @@ int main(int argc, char **argv) {
Invocation.getLangOptions().DisableAvailabilityChecking = true;
Invocation.getLangOptions().EnableAccessControl = false;
Invocation.getLangOptions().EnableObjCAttrRequiresFoundation = false;
if (Invocation.getLangOptions().Target.isOSBinFormatWasm())
Invocation.getLangOptions().EnableObjCInterop = false;

serialization::ExtendedValidationInfo extendedInfo;
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
Expand Down

0 comments on commit b335c43

Please sign in to comment.