Skip to content

Removed Linux use of sys/sysctl.h #2771

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

Merged
merged 1 commit into from
Apr 22, 2020
Merged

Conversation

tachoknight
Copy link
Contributor

The header is deprecated and removed in 5.5 of the kernel which causes Swift not to build.

@@ -27,7 +27,7 @@

#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD
#include <unistd.h>
#if !TARGET_OS_ANDROID
#if !TARGET_OS_ANDROID || !TARGET_OS_LINUX
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think TARGET_OS_ANDROID implies TARGET_IS_LINUX.

From CoreFoundation/Base.subproj/SwiftRuntime/TargetConditionals.h:

#elif __ANDROID__
#define TARGET_OS_DARWIN       0
#define TARGET_OS_LINUX        1
#define TARGET_OS_WINDOWS      0
#define TARGET_OS_BSD          0
#define TARGET_OS_ANDROID      1
#define TARGET_OS_CYGWIN       0

Copy link
Contributor Author

@tachoknight tachoknight Apr 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the patch to be inclusive of BSD and macOS, and not exclusive of Linux/Android

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included CFBundle_InfoPlist.c in the PR as it too includes sys/sysctl.h

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I confused this with the other file (CFBundle_InfoPlist.c). Is the #include even needed here on any target?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sysctl.h is still included for all Apple SDKs and is not marked as deprecated. I do not have a BSD box to verify what its status is.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that nothing in this file appears to use facilities from <sys/sysctl.h>, as far as I can see. There are no sysctl*, KERN_*, or CTL_* identifiers used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand. I see what you mean, but I wanted to keep the PR Linux-focused and not presume that it could be removed, regardless of platform.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was dropped in the final merge, @tachoknight, mistake?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I ran the tests natively on Android with both changes, ie including this one that was dropped in the final merge, and didn't have a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buttaface Sigh, yes, a rebasing mistake. I submitted this PR for the other file. Thanks a lot for noticing it.

@spevans
Copy link
Contributor

spevans commented Apr 18, 2020

@swift-ci test linux

@@ -17,7 +17,7 @@

#if (TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD) && !TARGET_OS_CYGWIN
#include <dirent.h>
#if !TARGET_OS_ANDROID
#if TARGET_OS_MAC || TARGET_OS_BSD
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call site for sysctlbyname is guarded by TARGET_OS_IPHONE, so perhaps use that here, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, TARGET_OS_IPHONE wasn't included in the original code, I'm leery of adding anything that could cause unintended side effects.

@compnerd
Copy link
Member

@swift-ci please test Linux platform

@tachoknight
Copy link
Contributor Author

The checks failed, but looking at the details, the errors don't seem related to this PR.

@spevans
Copy link
Contributor

spevans commented Apr 19, 2020

@swift-ci please test Linux platform

@tachoknight
Copy link
Contributor Author

Huh, that's really weird that it didn't work. /home/buildnode/jenkins/workspace/swift-corelibs-foundation-PR-Linux/llvm-project/lldb/test/Shell/Swift/Inputs/No.swiftmodule.swift:12:38: error: CHECK-DAG: expected string not found in input.

@compnerd
Copy link
Member

@tachoknight I don't think thats related to your change, please do address the last comment by @fweimer though.

@compnerd
Copy link
Member

@swift-ci please test Linux platform

1 similar comment
@compnerd
Copy link
Member

@swift-ci please test Linux platform

@spevans
Copy link
Contributor

spevans commented Apr 20, 2020

Is there anyway to test this change against android?

@3405691582
Copy link
Member

For the record, this builds OK standalone on OpenBSD (WIP, and modulo still open PRs), when cherrypicking this PR and using only TARGET_OS_MAC for sys/sysctl.h.

@compnerd
Copy link
Member

compnerd commented Apr 20, 2020

@spevans sure, I can do a run against android, seems that the last comment has been addressed, I’ll kick it off in a bit

@compnerd
Copy link
Member

@compnerd
Copy link
Member

@swift-ci please test Linux platform

@spevans
Copy link
Contributor

spevans commented Apr 20, 2020

Can these 3 commits be squashed down into 1 since this PR is only a 2line change?

@tachoknight
Copy link
Contributor Author

@spevans Would you like me to close this PR and open a new one with just the one change?

@spevans
Copy link
Contributor

spevans commented Apr 21, 2020

@tachoknight No need, you can do a rebase locally to squash all of the commits and then if you force push to github it will update the PR.

@tachoknight
Copy link
Contributor Author

@spevans: Done, sorry for the mess :)

@spevans
Copy link
Contributor

spevans commented Apr 22, 2020

@swift-ci linux test

@compnerd
Copy link
Member

@swift-ci please test Linux platform

@compnerd
Copy link
Member

Windows, Android, Linux, OpenBSD reporting in: passing.

Lets go ahead with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants