Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include sysctl.h on Linux. #660

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Sep 4, 2024

This PR ensures <sys/sysctl.h> is not included on Linux, where it generates compile-time diagnostics on distros/versions where it's still present. The diagnostic looks something like:

[5/5][100%][7.920s] Linking Swift shared library lib/libTesting.so
<module-includes>:3:10: note: in file included from <module-includes>:3:
1 | #include "./Defines.h"
2 | #include "./Discovery.h"
3 | #include "./Includes.h"
  |          `- note: in file included from <module-includes>:3:
4 | #include "./Stubs.h"
5 | #include "./TestSupport.h"

/home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61:10: note: in file included from /home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61:
 59 |
 60 | #if __has_include(<sys/sysctl.h>)
 61 | #include <sys/sysctl.h>
    |          `- note: in file included from /home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61:
 62 | #endif
 63 |

Since we don't use sysctl() on Linux (and it's been outright removed from the OS!), let's fix the diagnostic.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR ensures `<sys/sysctl.h>` is not included on Linux, where it generates compile-time diagnostics on distros/versions where it's still present. The diagnostic looks something like:

```
[5/5][100%][7.920s] Linking Swift shared library lib/libTesting.so
<module-includes>:3:10: note: in file included from <module-includes>:3:
1 | #include "./Defines.h"
2 | #include "./Discovery.h"
3 | #include "./Includes.h"
  |          `- note: in file included from <module-includes>:3:
4 | #include "./Stubs.h"
5 | #include "./TestSupport.h"

/home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61:10: note: in file included from /home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61:
 59 |
 60 | #if __has_include(<sys/sysctl.h>)
 61 | #include <sys/sysctl.h>
    |          `- note: in file included from /home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61:
 62 | #endif
 63 |
```

Since we don't use `sysctl()` on Linux (and it's been outright removed from the OS!), let's fix the diagnostic.
@grynspan grynspan added bug Something isn't working linux 🐧 Linux support (all distros) build Affects the project's build configuration or process labels Sep 4, 2024
@grynspan grynspan self-assigned this Sep 4, 2024
@grynspan
Copy link
Contributor Author

grynspan commented Sep 4, 2024

@swift-ci test

@grynspan grynspan merged commit 263545b into main Sep 4, 2024
3 checks passed
@grynspan grynspan deleted the jgrynspan/no-include-sysctl-on-linux branch September 4, 2024 19:23
@grynspan grynspan added this to the Swift 6.1 milestone Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Affects the project's build configuration or process linux 🐧 Linux support (all distros)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants