Commit bfa01fd3 authored by Drew's avatar Drew

Support bitcode

This currently only works for xcode-toolchain due to SR-1493

That being said, it does work, which is important for production iOS use
parent 238b651a
Pipeline #1912 passed with stage
......@@ -211,6 +211,7 @@ final class ATllbuild : Tool {
case WholeModuleOptimization = "whole-module-optimization"
case Framework = "framework"
case ExecutableName = "executable-name"
case Bitcode = "bitcode"
static var allOptions : [Options] {
......@@ -233,7 +234,8 @@ final class ATllbuild : Tool {
UmbrellaHeader,
WholeModuleOptimization,
Framework,
ExecutableName
ExecutableName,
Bitcode
]
}
}
......@@ -323,6 +325,20 @@ final class ATllbuild : Tool {
}
}
let bitcode: Bool
//do we have an explicit bitcode setting?
if let b = task[Options.Bitcode.rawValue] {
bitcode = b.bool!
}
else {
bitcode = false
}
//todo: enable by default for iOS, but we can't due to SR-1493
if bitcode {
compileOptions.append("-embed-bitcode")
linkOptions.append(contentsOf: ["-embed-bitcode"])
}
//check for modulemaps
for product in linkWithProduct {
let productName = product.split(character: ".")[0]
......
(package
:name "bitcode"
:tasks {
;;these tasks check bitcode support
;;static, dynamic, and executable targets
:bitcodebuilde {
:tool "atllbuild"
:sources ["src/**.swift"]
:name "e"
:output-type "executable"
:bitcode true
}
:bitcodebuilds {
:tool "atllbuild"
:sources ["src/**.swift"]
:name "s"
:output-type "static-library"
:bitcode true
}
:bitcodebuildd {
:tool "atllbuild"
:sources ["src/**.swift"]
:name "d"
:output-type "dynamic-library"
:bitcode true
}
:bitcodes {
:tool "packageatbin"
:name "s"
:atllbuild-task "bitcodebuilds"
:platforms ["all"]
}
:bitcoded {
:tool "packageatbin"
:name "d"
:atllbuild-task "bitcodebuildd"
:platforms ["all"]
}
:bitcodee {
:tool "packageatbin"
:name "e"
:atllbuild-task "bitcodebuilde"
:platforms ["all"]
}
:bitcode {
:tool "nop"
:dependencies ["bitcoded" "bitcodee" "bitcodes"]
}
}
)
\ No newline at end of file
class Foo { }
\ No newline at end of file
......@@ -8,7 +8,7 @@
:name "hello"
:output-type "executable"
:publish-product true
}
}
}
)
......@@ -17,6 +17,34 @@ if ! $ATBUILD package --use-overlay static; then
$ATBUILD package
fi
echo "****************BITCODE TEST**************"
cd $DIR/tests/fixtures/bitcode
#xcode toolchain is only supported on OSX
#and we only support bitcode on the xcode toolchain
if [ "$UNAME" == "Darwin" ]; then
$ATBUILD --platform ios --toolchain xcode bitcode
# verify bitcode sections exist
if ! otool -l bin/s.atbin/s.a | grep __LLVM; then
echo "No bitcode for static library"
exit 1
fi
if ! otool -l bin/d.atbin/d.dylib | grep __LLVM; then
echo "No bitcode for dynamic library"
exit 1
fi
if ! otool -l bin/e.atbin/e | grep __LLVM; then
echo "No bitcode for executable"
exit 1
fi
fi
echo "****************ONLY-PLATFORMS TEST**************"
cd $DIR/tests/fixtures/only_platforms
$ATBUILD > /tmp/only.txt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment