File tree Expand file tree Collapse file tree
docs/getting-started/new-project-guide
infra/base-images/base-builder-swift Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,8 +58,12 @@ instead of using the simple base-builder
5858
5959# ## build.sh
6060
61- A `precompile_swift` generates an environment variable `SWIFTFLAGS`
62- This can then be used in the building command such as `swift build -c release $SWIFTFLAGS`
61+ A `precompile_swift` generates two environment variables `SWIFTFLAGS` and
62+ ` SWIFT6_2FLAGS` . These can then be used in the building command such as `swift
63+ build -c release $SWIFTFLAGS`. If your `Package.swift` uses
64+ ` // swift-tools-version:6.2` or higher, then use `SWIFT6_2FLAGS` if us using
65+ something lower, you'll want to use `SWIFTFLAGS`. If you get errors like
66+ _undefined symbol '[BINARY\_NAME]\_main'_ then you likely need the 6_2 version.
6367
6468
6569A usage example from swift-protobuf project is
Original file line number Diff line number Diff line change 1717
1818cp /usr/local/bin/llvm-symbolizer-swift $OUT /llvm-symbolizer
1919
20+ # The flags needed depend on the `swift-tools-version` in the Package.swift, so
21+ # best we can do it provide two environment variable and let folks use the
22+ # correct one.
23+
2024export SWIFTFLAGS=" -Xswiftc -parse-as-library -Xswiftc -static-stdlib --static-swift-stdlib"
25+ export SWIFT6_2FLAGS=" -Xswiftc -static-stdlib --static-swift-stdlib"
2126if [ " $SANITIZER " = " coverage" ]
2227then
2328 export SWIFTFLAGS=" $SWIFTFLAGS -Xswiftc -profile-generate -Xswiftc -profile-coverage-mapping -Xswiftc -sanitize=fuzzer"
29+ export SWIFT6_2FLAGS=" $SWIFT6_2FLAGS -Xswiftc -profile-generate -Xswiftc -profile-coverage-mapping --sanitize=fuzzer"
2430else
2531 export SWIFTFLAGS=" $SWIFTFLAGS -Xswiftc -sanitize=fuzzer,$SANITIZER --sanitize=$SANITIZER "
32+ export SWIFT6_2FLAGS=" $SWIFT6_2FLAGS --sanitize=fuzzer --sanitize=$SANITIZER "
2633 for f in $CFLAGS ; do
2734 export SWIFTFLAGS=" $SWIFTFLAGS -Xcc=$f "
35+ export SWIFT6_2FLAGS=" $SWIFT6_2FLAGS -Xcc=$f "
2836 done
2937
3038 for f in $CXXFLAGS ; do
3139 export SWIFTFLAGS=" $SWIFTFLAGS -Xcxx=$f "
40+ export SWIFT6_2FLAGS=" $SWIFT6_2FLAGS -Xcxx=$f "
3241 done
3342fi
Original file line number Diff line number Diff line change 1919. precompile_swift
2020cd FuzzTesting
2121
22-
23- # Normally one would use `$SWIFTFLAGS` (from `precompile_swift``) on this
24- # invocations, but as we found in
25- # https://github.com/apple/swift-protobuf/pull/2037, the flags needs depend on
26- # *both* the Swift Toolchain version *and& the `swift-tools-version` in the
27- # `Package.swift`.
28- #
29- # So, for now, manually recode `precompile_swift` with the flags needed since
30- # swift-protobuf uses a 6.2+ `swift-tools-version`.
31- export SWIFTFLAGS=" -Xswiftc -static-stdlib --static-swift-stdlib"
32- if [ " $SANITIZER " = " coverage" ] ; then
33- export SWIFTFLAGS=" $SWIFTFLAGS -Xswiftc -profile-generate -Xswiftc -profile-coverage-mapping --sanitize=fuzzer"
34- else
35- export SWIFTFLAGS=" $SWIFTFLAGS --sanitize=fuzzer --sanitize=$SANITIZER "
36- for f in $CFLAGS ; do
37- export SWIFTFLAGS=" $SWIFTFLAGS -Xcc=$f "
38- done
39-
40- for f in $CXXFLAGS ; do
41- export SWIFTFLAGS=" $SWIFTFLAGS -Xcxx=$f "
42- done
43- fi
44-
4522# debug build
46- swift build -c debug $SWIFTFLAGS
23+ swift build -c debug $SWIFT6_2FLAGS
4724(
4825cd .build/debug/
4926find . -maxdepth 1 -type f -name " Fuzz*" -executable | while read i; do cp $i $OUT /" $i " _debug; done
5027)
5128
5229# release build
53- swift build -c release $SWIFTFLAGS
30+ swift build -c release $SWIFT6_2FLAGS
5431(
5532cd .build/release/
5633find . -maxdepth 1 -type f -name " Fuzz*" -executable | while read i; do cp $i $OUT /" $i " _release; done
You can’t perform that action at this time.
0 commit comments