1+ ############################################################################
2+ # tools/Swift.defs
3+ #
4+ # Licensed to the Apache Software Foundation (ASF) under one or more
5+ # contributor license agreements. See the NOTICE file distributed with
6+ # this work for additional information regarding copyright ownership. The
7+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8+ # "License"); you may not use this file except in compliance with the
9+ # License. You may obtain a copy of the License at
10+ #
11+ # http://www.apache.org/licenses/LICENSE-2.0
12+ #
13+ # Unless required by applicable law or agreed to in writing, software
14+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+ # License for the specific language governing permissions and limitations
17+ # under the License.
18+ #
19+ ############################################################################
20+
21+ # required: Swift 6
22+
23+ SWIFTC := swiftc
24+
25+ SWIFTFLAGS := -enable-experimental-feature Embedded -wmo
26+
27+ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
28+ SWIFTFLAGS += -g
29+ endif
30+
31+ ifeq ($(CONFIG_DEBUG_NOOPT),y)
32+ SWIFTFLAGS += -Osize
33+ endif
34+
35+ # Special handling for the SIM
36+
37+ ifeq ($(CONFIG_ARCH_SIM),y)
38+ ifeq ($(CONFIG_HOST_LINUX),y)
39+ ifeq ($(LLVM_ARCHTYPE),x86)
40+ # Only for x86 based host or x64 but m32 build
41+ SWIFTFLAGS += -target i686-unknown-linux-$(LLVM_ABITYPE)
42+ else
43+ # For other archs, such as aarch64, arm etc
44+ SWIFTFLAGS += -target $(LLVM_ARCHTYPE)-unknown-linux-$(LLVM_ABITYPE)
45+ SWIFTFLAGS += -target-cpu $(LLVM_CPUTYPE)
46+ endif
47+ else ifeq ($(CONFIG_HOST_MACOS),y)
48+ # Triple target [x86/arm64]-apple-macosx[min_version]
49+ ifeq ($(LLVM_ARCHTYPE),aarch64)
50+ SWIFTFLAGS += -target arm64-apple-macosx11.7.1
51+ else
52+ SWIFTFLAGS += -target $(LLVM_ARCHTYPE)-apple-macosx10.9.0
53+ endif
54+ endif
55+ else ifeq ($(CONFIG_ARCH_RISCV),y)
56+ # Target triple is riscv[32|64]-unknown-none-eabi
57+ SWIFTFLAGS += -target $(LLVM_ARCHTYPE)-none-none-eabi
58+ ifeq ($(CONFIG_ARCH_FPU),y)
59+ SWIFTFLAGS += -Xcc -march=rv32imafc_zicsr_zifencei
60+ else ifeq ($(CONFIG_ARCH_DPFPU),y)
61+ SWIFTFLAGS := -Xcc -march=rv32imafdc_zicsr_zifencei
62+ else
63+ SWIFTFLAGS += -Xcc -march=rv32imac_zicsr_zifencei
64+ endif
65+
66+ # Handle ABI and CPU
67+ ifeq ($(CONFIG_ARCH_RV32),y)
68+ SWIFTFLAGS += -target-cpu generic-rv32
69+ SWIFTFLAGS += -Xcc -mabi=ilp32d
70+ else ifeq ($(CONFIG_ARCH_RV64),y)
71+ SWIFTFLAGS += -target-cpu generic-rv64
72+ SWIFTFLAGS += -Xcc -mabi=lp64d
73+ endif
74+ else
75+ # For arm, but there are some other archs not support yet,
76+ # such as xtensa, x86 bare metal, etc.
77+ SWIFTFLAGS += -target $(LLVM_ARCHTYPE)-none-none-$(LLVM_ABITYPE)
78+ SWIFTFLAGS += -target-cpu $(LLVM_CPUTYPE)
79+ endif
80+
81+
82+ # Note for reference - all embedded targets available
83+ # see: ls ${SWIFT_PREFIX_PATH}/lib/swift/embedded/Swift.swiftmodule/
84+ #
85+ # aarch64-none-none-elf, arm64-apple-none-macho,
86+ # armv4t-none-none-eabi, armv6-apple-none-macho, armv6-none-none-eabi,
87+ # armv6m-apple-none-macho, armv6m-none-none-eabi, armv7-apple-none-macho,
88+ # armv7-none-none-eabi, armv7em-apple-none-macho, armv7em-none-none-eabi,
89+ # avr-none-none-elf, i686-unknown-none-elf, riscv32-none-none-eabi,
90+ # riscv64-none-none-eabi, wasm32-unknown-none-wasm, wasm64-unknown-none-wasm,
91+ # x86_64-unknown-linux-gnu, x86_64-unknown-none-elf,
0 commit comments