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

unzip: fix configure script when using clang 16 #235121

Merged
merged 1 commit into from
Jun 11, 2023

Conversation

reckenrode
Copy link
Contributor

Description of changes

Clang 16 makes implicit int and function declarations an error by default in any mode except for C89. The configure script has two of these that cause it to misdetect features when using Clang 16.

  • Implicit int main in the errno check. This is fixed by adding the missing int.
  • Implicit definitions of opendir and closedir. These are fixed by declaring the function definitions directly in conftest.c.

For opendir and closedir, I opted not to include dirent.h because the test is checking which library to link. Whether dirent.h can be used is checked separately. Using this approach preserves the intent of the check while fixing the incompatibility.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Comment on lines 16 to 18
+typedef struct _dir DIR;
+DIR* opendir(const char*);
+int closedir(DIR*);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the correct fix is to include the headers that define it:

#include <sys/types.h>
#include <dirent.h>

Maybe we could borrow the fix from other distributions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reasoning for not using the headers here is that this particular test is determining which library has those symbols. It checks which headers to include later. I was trying to preserve that original separation of checks.

In practice, it shouldn’t matter for the platforms nixpkgs supports. If you’d rather I not bother, I can push an updated patch that just includes those headers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion for this case.

Generally it's easy to cause unintended breakage by defining slightly incompatible prototypes (macros vs symbols, struct mismatch, struct fs integral typedef, -static -flto seeing through struct definitions). Would be unfortunate if it comes back and bites us later on more exotic target or toolchain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it’s a bad test. It just checks for the first library that happens not to have missing symbols when you try to link it. I went ahead and pushed a commit to use the headers.

@trofi trofi requested review from trofi and removed request for trofi May 31, 2023 17:37
Comment on lines 16 to 18
+typedef struct _dir DIR;
+DIR* opendir(const char*);
+int closedir(DIR*);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion for this case.

Generally it's easy to cause unintended breakage by defining slightly incompatible prototypes (macros vs symbols, struct mismatch, struct fs integral typedef, -static -flto seeing through struct definitions). Would be unfortunate if it comes back and bites us later on more exotic target or toolchain.

Clang 16 makes implicit int and function declarations an error by
default in any mode except for C89. The configure script has two of
these that cause it to misdetect features when using Clang 16.

* Implicit `int main` in the errno check. This is fixed by adding the
  missing `int`.
* Implicit definitions of `opendir` and `closedir`. These are fixed by
  including the required headers.
@vcunat vcunat merged commit 0d6c7b6 into NixOS:staging Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants