mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
LLJIT is a simple LLVM IR JIT. Its interface is similar to MCJIT, but its implementation is based on LLVM's newer ORC APIs. This initial patch does not make use of any of LLJIT/ORC's advanced features, but will provide better diagnostics when JIT'd code fails to link. Once LLJIT has proven usable in this basic configuration we can start experimenting with more advanced features, including lazy compilation.
43 lines
1.0 KiB
Swift
43 lines
1.0 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: echo "int global() { return 42; }" | %clang -dynamiclib -o %t/libLinkMe.dylib -x c -
|
|
// RUN: %target-swift-frontend -emit-module -parse-stdlib -o %t -module-name LinkMe -module-link-name LinkMe %S/../../Inputs/empty.swift
|
|
|
|
// RUN: %target-jit-run -DIMPORT %s -I %t -L %t 2>&1
|
|
// RUN: %target-jit-run -lLinkMe %s -L %t 2>&1
|
|
// RUN: not %target-jit-run -lLinkMe %s 2>&1
|
|
|
|
// RUN: %target-jit-run -lLinkMe -DUSE_DIRECTLY %s -L %t 2>&1
|
|
// RUN: not %target-jit-run -DUSE_DIRECTLY -lLinkMe %s 2>&1
|
|
// REQUIRES: executable_test
|
|
|
|
|
|
// This is specifically testing autolinking for immediate mode. Please do not
|
|
// change it to use %target-build/%target-run
|
|
// REQUIRES: swift_interpreter
|
|
// REQUIRES: OS=macosx
|
|
|
|
|
|
import Darwin
|
|
#if IMPORT
|
|
import LinkMe
|
|
#endif
|
|
|
|
|
|
#if USE_DIRECTLY
|
|
|
|
@_silgen_name("global")
|
|
func global() -> Int32
|
|
|
|
if global() != 42 {
|
|
exit(EXIT_FAILURE)
|
|
}
|
|
|
|
#else
|
|
|
|
let RTLD_DEFAULT = UnsafeMutableRawPointer(bitPattern: -2)
|
|
if dlsym(RTLD_DEFAULT, "global") == nil {
|
|
print(String(cString: dlerror()))
|
|
exit(EXIT_FAILURE)
|
|
}
|
|
#endif
|