Skip to content

Commit 36728d7

Browse files
committed
[docs] Update docs for OpenBSD.
When making debug builds, `Decl.cpp` compiles with a large number of ELF section headers; including randomdata sections as normally included by the platform for security purposes, this may in reality exceed the ELF limit of `SHN_LORESERVE`. In this case, the ELF header field containing the number of section headers, `e_shnum`, is set to 0 and the real number of section headers is stored elsewhere. However, when an object file has no section headers, this field is also set to 0. OpenBSD uses the GNU binutils by default. These binutils do not handle the case when `e_shnum` is 0, and assume that the object file has no section headers. But the only tool that counts is the static archive tool `ar`. When creating the archive index, `ar` encounters `Decl.cpp.o` as part of `libswiftAST.a`, notes that `e_shnum` is 0, and skips the object file entirely, presumably because it thinks the object file has no section headers and therefore no symbols. This leads the linker to assume that symbols in `Decl.cpp.o` are not part of `libswiftAST.a`, when in fact they are. The LLVM version of `ar` does not appear to have this bug. Since this is only a problem that is more likely to occur on debug builds and workarounds like enabling LTO can alleviate the problem, do not recommend that the `llvm` package be added as part of the standard package dependency set, but merely note that using `llvm-ar` can work around the problem. Indeed, future OpenBSD versions may include updated binutils which may have this bug fixed. While we are here, the new concurrency features require libdispatch, and since some of the necessary patches to libdispatch have not yet been reviewed or accepted upstream yet to make it work on OpenBSD, recommend that prospective builders for this platform still disable features that depend on libdispatch for now. Additionally, update the platform version number which has been tested.
1 parent 31e460b commit 36728d7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/OpenBSD.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting started with Swift on OpenBSD
22

3-
Swift builds and runs on OpenBSD (tested on 6.8-beta), with some special considerations.
3+
Swift builds and runs on OpenBSD (tested on 6.8), with some special considerations.
44

55
## Preparing
66

@@ -66,7 +66,7 @@ These options are:
6666
* `--skip-build-clang-tools-extra` and `--skip-build-compiler-rt`: to ensure LLVM builds cleanly,
6767
* `--extra-cmake-options=`
6868
* `-DCMAKE_DISABLE_FIND_PACKAGE_Backtrace=TRUE,-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=TRUE,-DLLVM_VERSION_SUFFIX=''`: to ensure LLVM builds cleanly,
69-
* `-DSWIFT_BUILD_SOURCEKIT=OFF,-DSWIFT_BUILD_SYNTAXPARSERLIB=OFF`: to ensure Swift does not attempt to build libdispatch, which is not yet supported on OpenBSD,
69+
* `-DSWIFT_BUILD_SOURCEKIT=OFF,-DSWIFT_BUILD_SYNTAXPARSERLIB=OFF,-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=OFF`: to ensure Swift does not attempt to build libdispatch, which is not yet supported on OpenBSD,
7070
* `-DSWIFT_USE_LINKER=lld`: to specify that `lld` should be used over `gold`,
7171
* `-DCMAKE_INSTALL_DIR=/usr/local"`: to set the correct platform install directory.
7272

@@ -81,8 +81,11 @@ $ ./utils/build-script \
8181
-DLLVM_VERSION_SUFFIX='',\
8282
-DSWIFT_BUILD_SOURCEKIT=OFF,\
8383
-DSWIFT_BUILD_SYNTAXPARSERLIB=OFF,\
84+
-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=OFF,\
8485
-DSWIFT_USE_LINKER=lld,\
8586
-DCMAKE_INSTALL_DIR=/usr/local"
8687
```
8788

8889
You may wish to also supply the flag `--llvm-targets-to-build=host`, to speed up the LLVM build slightly.
90+
91+
For debug builds especially, consider also installing the `llvm` package and setting `-DCMAKE_AR=/usr/local/bin/llvm-ar` with the `extra-cmake-options` flag, to work around problems creating indexes to archives containing object files with large numbers of section headers.

0 commit comments

Comments
 (0)