Skip to content

Commit efb38ce

Browse files
authored
Merge pull request #75 from kkebo/toolset
build: use toolset.json
2 parents 9da7c40 + b57264d commit efb38ce

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

Makefile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
LIB := .build/release/libKernel.a
2-
EXE := .build/kernel.elf
1+
EXE := .build/release/Kernel
32
IMG := .build/kernel8.img
4-
MAP := .build/kernel.map
3+
TOOLSET := toolset.json
54
LINKER_SCRIPT := linker.ld
65

76
TRIPLE := aarch64-none-none-elf
87
SWIFT := swift
9-
SWIFT_BUILD_FLAGS := --triple $(TRIPLE) -c release -Xswiftc -Osize \
8+
SWIFT_BUILD_FLAGS := --triple $(TRIPLE) --toolset $(TOOLSET) -c release -Xswiftc -Osize \
109
--experimental-lto-mode=full -Xswiftc -experimental-hermetic-seal-at-link
11-
LD := clang -fuse-ld=lld
12-
LDFLAGS := --target=$(TRIPLE) -nostdlib -static -Wl,--gc-sections,--print-gc-sections,--strip-all
1310
OBJCOPY := llvm-objcopy
1411
QEMU := qemu-system-aarch64
1512

1613
.PHONY: all
1714
all: $(IMG)
1815

19-
$(EXE): Makefile $(LINKER_SCRIPT) $(LIB)
20-
$(LD) $(LDFLAGS) -T $(LINKER_SCRIPT) -Xlinker -Map=$(MAP) $(LIB) -o $@
21-
2216
$(IMG): Makefile $(EXE)
2317
$(OBJCOPY) $(EXE) -O binary $@
2418

25-
$(LIB): Makefile .swift-version Package.swift $(wildcard Package.resolved) Sources
19+
$(EXE): Makefile .swift-version $(TOOLSET) $(LINKER_SCRIPT) Package.swift $(wildcard Package.resolved) Sources
2620
$(SWIFT) build $(SWIFT_BUILD_FLAGS)
2721

2822
.PHONY: run

Package.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
import PackageDescription
44

55
let swiftSettings: [SwiftSetting] = [
6-
.enableExperimentalFeature("Embedded"),
76
.enableExperimentalFeature("LifetimeDependence"),
8-
.unsafeFlags(["-Xfrontend", "-no-allocations"]),
9-
.unsafeFlags(["-Xfrontend", "-function-sections"]),
10-
.unsafeFlags(["-Xfrontend", "-disable-stack-protector"]),
11-
.unsafeFlags(["-Xfrontend", "-mergeable-symbols"]),
127
.unsafeFlags(["-strict-memory-safety"]),
138
]
149

1510
let package = Package(
1611
name: "swift_os",
1712
products: [
18-
.library(name: "Kernel", type: .static, targets: ["Kernel"])
13+
.executable(name: "Kernel", targets: ["Kernel"])
1914
],
2015
traits: [
2116
.default(enabledTraits: ["RASPI4"]),
@@ -26,7 +21,7 @@ let package = Package(
2621
"RASPI",
2722
],
2823
targets: [
29-
.target(
24+
.executableTarget(
3025
name: "Kernel",
3126
dependencies: [
3227
"AsmSupport",

Sources/AsmSupport/aarch64/boot.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _start:
2626
cbnz w2, 3b
2727

2828
// jump to Swift code, should not return
29-
4: bl main
29+
4: bl Kernel_main
3030
// for failsafe, halt this core too
3131
b 1b
3232

toolset.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"schemaVersion": "1.0",
3+
"swiftCompiler": {
4+
"extraCLIOptions": [
5+
"-enable-experimental-feature", "Embedded",
6+
"-Xfrontend", "-no-allocations",
7+
"-Xfrontend", "-function-sections",
8+
"-Xfrontend", "-disable-stack-protector",
9+
"-Xfrontend", "-mergeable-symbols",
10+
"-Xclang-linker", "-nostdlib",
11+
"-Xclang-linker", "-fuse-ld=lld",
12+
]
13+
},
14+
"linker": {
15+
"extraCLIOptions": [
16+
"-nostdlib",
17+
"-static",
18+
"--gc-sections",
19+
"--print-gc-sections",
20+
"--strip-all",
21+
"-T", "linker.ld",
22+
"-Map", ".build/kernel.map",
23+
]
24+
}
25+
}

0 commit comments

Comments
 (0)