Skip to content

Fix sil-func-extractor and driver #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 25, 2019
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
7 changes: 6 additions & 1 deletion lib/Driver/UnixToolChains.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -1226,10 +1226,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 @@ -1246,7 +1266,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
Original file line number Diff line number Diff line change
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