Commit c07f2162 authored by Drew's avatar Drew Committed by GitHub

Merge pull request #111 from AnarchyTools/config-impl

Add actual effects to the configurations
parents dc20b2ad 3c62219a
Pipeline #2201 failed with stage
in 63 minutes and 10 seconds
...@@ -13,6 +13,15 @@ ...@@ -13,6 +13,15 @@
// limitations under the License. // limitations under the License.
public enum Configuration { public enum Configuration {
public enum DebugInstrumentationType {
///Instrumentation should be included in the target
case Included
///No instrumentation for the target
case Omitted
///Instumentation should be generated separately, e.g. DWARF
case Stripped
}
///Built-in configurations ///Built-in configurations
///The default configuration. ///The default configuration.
...@@ -105,4 +114,13 @@ extension Configuration { ...@@ -105,4 +114,13 @@ extension Configuration {
case .User: return nil case .User: return nil
} }
} }
///Whether debug instrumentation
var debugInstrumentation: DebugInstrumentationType {
switch(self) {
case .Debug, .Test: return .Included
case .Release, .Benchmark: return .Stripped
case .User, .None: return .Omitted
}
}
} }
\ No newline at end of file
...@@ -176,9 +176,13 @@ class PackageAtbin:Tool { ...@@ -176,9 +176,13 @@ class PackageAtbin:Tool {
let cmd: String let cmd: String
switch Platform.hostPlatform { switch Platform.hostPlatform {
case .OSX: case .OSX:
cmd = "tar c --options \"xz:compression-level=9\" -Jf \(tarxz) bin/\(name).atbin -C bin" let fc = currentConfiguration.fastCompile == true
let compressionLevel = fc ? "0" :"9"
cmd = "tar c --options \"xz:compression-level=\(compressionLevel)\" -Jf \(tarxz) bin/\(name).atbin -C bin"
case .Linux: case .Linux:
cmd = "XZ_OPT=-8 tar cJf \(tarxz) bin/\(name).atbin -C bin" let fc = currentConfiguration.fastCompile == true
let compressionLevel = fc ? "0" :"8"
cmd = "XZ_OPT=-\(compressionLevel) tar cJf \(tarxz) bin/\(name).atbin -C bin"
default: default:
fatalError("Unsupported host platform \(Platform.hostPlatform)") fatalError("Unsupported host platform \(Platform.hostPlatform)")
} }
......
...@@ -54,6 +54,19 @@ final class Shell : Tool { ...@@ -54,6 +54,19 @@ final class Shell : Tool {
mysetEnv("ATBUILD_CONFIGURATION_NO_MAGIC", o ? "1":"0") mysetEnv("ATBUILD_CONFIGURATION_NO_MAGIC", o ? "1":"0")
} }
//expose debug configuration info
let conf: String
switch (currentConfiguration.debugInstrumentation) {
case .Included:
conf = "included"
case .Omitted:
conf = "omitted"
case .Stripped:
conf = "stripped"
}
mysetEnv("ATBUILD_CONFIGURATION_DEBUG_INSTRUMENTATION", conf)
//does bin path not exist? //does bin path not exist?
//let's create it! //let's create it!
let binPath = try! FS.getWorkingDirectory().appending("bin") let binPath = try! FS.getWorkingDirectory().appending("bin")
......
...@@ -329,7 +329,7 @@ final class ATllbuild : Tool { ...@@ -329,7 +329,7 @@ final class ATllbuild : Tool {
let _ = try? FS.createDirectory(path: workDirectory.appending("objects")) let _ = try? FS.createDirectory(path: workDirectory.appending("objects"))
let _ = try? FS.createDirectory(path: workDirectory.appending("include")) let _ = try? FS.createDirectory(path: workDirectory.appending("include"))
//parse arguments ///MARK: parse arguments
var linkWithProduct: [String] = [] var linkWithProduct: [String] = []
if let arr_ = task[Options.LinkWithProduct.rawValue] { if let arr_ = task[Options.LinkWithProduct.rawValue] {
guard let arr = arr_.vector else { guard let arr = arr_.vector else {
...@@ -591,15 +591,6 @@ final class ATllbuild : Tool { ...@@ -591,15 +591,6 @@ final class ATllbuild : Tool {
///The next task will not be bootstrapped. ///The next task will not be bootstrapped.
defer { Platform.buildPlatform = Platform.hostPlatform } defer { Platform.buildPlatform = Platform.hostPlatform }
if task[Options.Magic.rawValue] == nil || task[Options.Magic.rawValue]?.bool == true {
switch(Platform.buildPlatform) {
case .OSX:
linkOptions.append(contentsOf: ["-Xlinker","-dead_strip"])
default:
break
}
}
let sdk: Bool let sdk: Bool
if task[Options.LinkSDK.rawValue]?.bool == false { if task[Options.LinkSDK.rawValue]?.bool == false {
sdk = false sdk = false
...@@ -616,16 +607,73 @@ final class ATllbuild : Tool { ...@@ -616,16 +607,73 @@ final class ATllbuild : Tool {
} }
let swiftCPath = findToolPath(toolName: "swiftc", toolchain: toolchain) let swiftCPath = findToolPath(toolName: "swiftc", toolchain: toolchain)
let enableWMO: Bool var enableWMO: Bool
if let wmo = task[Options.WholeModuleOptimization.rawValue]?.bool { if let wmo = task[Options.WholeModuleOptimization.rawValue]?.bool {
enableWMO = wmo enableWMO = wmo
//we can't deprecate WMO due to a bug in swift-preview-1 that prevents it from being useable in some cases on Linux
} }
else { enableWMO = false } else { enableWMO = false }
// MARK: Configurations
if currentConfiguration.testingEnabled == true {
compileOptions.append("-enable-testing")
}
//"stripped" is implemented as "included" here, that is a bug
//see https://github.com/AnarchyTools/atbuild/issues/73
if currentConfiguration.debugInstrumentation == .Included || currentConfiguration.debugInstrumentation == .Stripped {
compileOptions.append("-g")
}
if currentConfiguration.optimize == true {
compileOptions.append("-O")
switch(Platform.buildPlatform) {
case .Linux:
//don't enable WMO on Linux
//due to bug in swift-preview-1
break
default:
enableWMO = true
}
}
if task[Options.Magic.rawValue] != nil {
print("Warning: Magic is deprecated. Please migrate to --configuration none. If --configuration none won't work for your usecase, file a bug at https://github.com/AnarchyTools/atbuild/issues")
sleep(5)
}
if currentConfiguration.fastCompile==false && task[Options.Magic.rawValue]?.bool != false {
switch(Platform.buildPlatform) {
case .OSX:
linkOptions.append(contentsOf: ["-Xlinker","-dead_strip"])
default:
break
}
}
switch(currentConfiguration) {
case .Debug:
compileOptions.append("-DATBUILD_DEBUG")
case .Release:
compileOptions.append("-DATBUILD_RELEASE")
case .Benchmark:
compileOptions.append("-DATBUILD_BENCH")
case .Test:
compileOptions.append("-DATBUILD_TEST")
case .None:
break //too much magic to insert an arg in this case
case .User(let str):
compileOptions.append("-DATBUILD_\(str)")
}
// MARK: emit llbuildyaml
let yaml = llbuildyaml(sources: sources, workdir: workDirectory, modulename: name, linkSDK: sdk, compileOptions: compileOptions, linkOptions: linkOptions, outputType: outputType, linkWithProduct: linkWithProduct, linkWithAtbin: linkWithAtbin, swiftCPath: swiftCPath, executableName: executableName, enableWMO: enableWMO) let yaml = llbuildyaml(sources: sources, workdir: workDirectory, modulename: name, linkSDK: sdk, compileOptions: compileOptions, linkOptions: linkOptions, outputType: outputType, linkWithProduct: linkWithProduct, linkWithAtbin: linkWithAtbin, swiftCPath: swiftCPath, executableName: executableName, enableWMO: enableWMO)
let _ = try? yaml.write(to: llbuildyamlpath) let _ = try? yaml.write(to: llbuildyamlpath)
if bootstrapOnly { return } if bootstrapOnly { return }
//MARK: execute build
switch moduleMap { switch moduleMap {
case .None: case .None:
break break
...@@ -638,7 +686,6 @@ final class ATllbuild : Tool { ...@@ -638,7 +686,6 @@ final class ATllbuild : Tool {
} }
} }
//SR-566
let cmd = "\(findToolPath(toolName: "swift-build-tool",toolchain: toolchain)) -f \(llbuildyamlpath)" let cmd = "\(findToolPath(toolName: "swift-build-tool",toolchain: toolchain)) -f \(llbuildyamlpath)"
anarchySystem(cmd) anarchySystem(cmd)
if task[Options.PublishProduct.rawValue]?.bool == true { if task[Options.PublishProduct.rawValue]?.bool == true {
......
...@@ -17,5 +17,13 @@ ...@@ -17,5 +17,13 @@
} }
} }
} }
:build {
:tool "atllbuild"
:sources ["src/**.swift"]
:name "conftest"
:output-type "executable"
:publish-product true
}
} }
) )
\ No newline at end of file
#if ATBUILD_DEBUG
print("Debug build")
#elseif ATBUILD_RELEASE
print("Release build")
#elseif ATBUILD_TEST
print("Test build")
#elseif ATBUILD_BENCH
print("Bench build")
#elseif ATBUILD_JAMES_BOND
print("James bond build")
#endif
\ No newline at end of file
...@@ -19,7 +19,7 @@ commands: ...@@ -19,7 +19,7 @@ commands:
module-name: platforms module-name: platforms
module-output-path: .atllbuild/products/platforms.swiftmodule module-output-path: .atllbuild/products/platforms.swiftmodule
temps-path: .atllbuild/llbuildtmp temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-D", "LINUX"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-D", "LINUX", "-g", "-DATBUILD_DEBUG"]
<atllbuild>: <atllbuild>:
tool: shell tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o"] inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o"]
......
...@@ -19,10 +19,10 @@ commands: ...@@ -19,10 +19,10 @@ commands:
module-name: platforms module-name: platforms
module-output-path: .atllbuild/products/platforms.swiftmodule module-output-path: .atllbuild/products/platforms.swiftmodule
temps-path: .atllbuild/llbuildtmp temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk", "-D", "OSX"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk", "-D", "OSX", "-g", "-DATBUILD_DEBUG"]
<atllbuild>: <atllbuild>:
tool: shell tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o"] inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o"]
outputs: ["<atllbuild>", ".atllbuild/products/platforms"] outputs: ["<atllbuild>", ".atllbuild/products/platforms"]
args: ["/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc", "-o", ".atllbuild/products/platforms", ".atllbuild/objects/main.swift.o", "-Xlinker", "-dead_strip"] args: ["/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc", "-o", ".atllbuild/products/platforms", ".atllbuild/objects/main.swift.o"]
description: Linking executable .atllbuild/products/platforms description: Linking executable .atllbuild/products/platforms
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
:name "wmo" :name "wmo"
:output-type "static-library" :output-type "static-library"
:publish-product true :publish-product true
:whole-module-optimization true
:compile-options ["-O"]
} }
} }
......
...@@ -11,11 +11,7 @@ pwd ...@@ -11,11 +11,7 @@ pwd
echo "****************SELF-HOSTING TEST**************" echo "****************SELF-HOSTING TEST**************"
if ! $ATBUILD package --use-overlay static; then $ATBUILD atbuild
echo "Self-host failed; maybe you're not running CaffeinatedSwift?"
echo "Retrying with non-static build"
$ATBUILD package
fi
echo "****************CONFIGURATION TEST**************" echo "****************CONFIGURATION TEST**************"
...@@ -38,6 +34,42 @@ if ! grep "\-always some flag --bond james bond" /tmp/configurations.txt; then ...@@ -38,6 +34,42 @@ if ! grep "\-always some flag --bond james bond" /tmp/configurations.txt; then
exit 1 exit 1
fi fi
## try atllbuild-level config
$ATBUILD --configuration debug build
bin/conftest > /tmp/configurations.txt
if ! grep "Debug build" /tmp/configurations.txt; then
echo "Invalid configuration behavior"
exit 1
fi
$ATBUILD --configuration release build
bin/conftest > /tmp/configurations.txt
if ! grep "Release build" /tmp/configurations.txt; then
echo "Invalid configuration behavior"
exit 1
fi
$ATBUILD --configuration test build
bin/conftest > /tmp/configurations.txt
if ! grep "Test build" /tmp/configurations.txt; then
echo "Invalid configuration behavior"
exit 1
fi
$ATBUILD --configuration bench build
bin/conftest > /tmp/configurations.txt
if ! grep "Bench build" /tmp/configurations.txt; then
echo "Invalid configuration behavior"
exit 1
fi
$ATBUILD --configuration JAMES_BOND build
bin/conftest > /tmp/configurations.txt
if ! grep "James bond build" /tmp/configurations.txt; then
echo "Invalid configuration behavior"
exit 1
fi
echo "****************BITCODE TEST**************" echo "****************BITCODE TEST**************"
...@@ -403,7 +435,7 @@ $ATBUILD ...@@ -403,7 +435,7 @@ $ATBUILD
echo "****************WMO TEST**************" echo "****************WMO TEST**************"
cd $DIR/tests/fixtures/wmo cd $DIR/tests/fixtures/wmo
$ATBUILD $ATBUILD --configuration release
echo "****************UMBRELLA TEST**************" echo "****************UMBRELLA TEST**************"
cd $DIR/tests/fixtures/umbrella_header cd $DIR/tests/fixtures/umbrella_header
...@@ -542,4 +574,15 @@ if $ATBUILD --use-overlay foo; then ...@@ -542,4 +574,15 @@ if $ATBUILD --use-overlay foo; then
exit 1 exit 1
fi fi
printf "\e[1m\e[32m***ATBUILD TEST SCRIPT PASSED SUCCESSFULLY*****\e[0m" printf "\e[1m\e[32m***ATBUILD TESTS PASSED SUCCESSFULLY*****\e[0m\n"
\ No newline at end of file
echo "*****************PACKAGING**********************"
cd $DIR
if ! $ATBUILD package --use-overlay static --configuration release; then
echo "Self-host failed; maybe you're not running CaffeinatedSwift?"
echo "Retrying with non-static build"
$ATBUILD package --configuration release
fi
printf "\e[1m\e[32m***ATBUILD BUILT SUCCESSFULLY*****\e[0m\n"
\ No newline at end of file
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