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

[libraries] System.Native fails to build with clang-13 #60326

Closed
lambdageek opened this issue Oct 13, 2021 · 5 comments · Fixed by #60328
Closed

[libraries] System.Native fails to build with clang-13 #60326

lambdageek opened this issue Oct 13, 2021 · 5 comments · Fixed by #60328
Labels
area-Infrastructure-libraries untriaged New issue has not been triaged by the area owner

Comments

@lambdageek
Copy link
Member

lambdageek commented Oct 13, 2021

Repro:

  1. Install clang-13 and libicu-dev (I have 67.1-7 on Debian testing)
  2. Compile the native library code.

Expected result: Build succeeds

Actual result: build fails with

/home/aleksey/working/dotnet-runtime/src/libraries/Native/Unix/System.Globalization.Native/pal_casing.c(47,13): error G57817EDC: identifier '__c2' is reserved because it starts with '__' [-Werror,-Wreserved-identifier] [/home/aleksey/working/dotnet-runtime/src/libraries/Native/build-native.proj]
              U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
              ^
  /usr/include/unicode/utf16.h:311:18: note: expanded from macro 'U16_NEXT'
          uint16_t __c2; \
                   ^

This is happening because -Weverything includes the new -Wreserved-identifier warning (more here)

add_compile_options(-Weverything)


At least ICU and openssl are affected.


There are also warnings about -Wunused-but-set-variable (also new in clang-13) and -Wcast-function-type (doesn't seem new also new in clang-13, though not in the release notes llvm/llvm-project@217f0f7)

/home/aleksey/working/dotnet-runtime/src/libraries/Native/Unix/System.Native/pal_signal.c(629,10): error G6B6BB85B: variable 'installed' set but not used [-Werror,-Wunused-but-set-variable] [/home/aleksey/working/dotnet-runtime/src/libraries/Native/build-native.proj]
      bool installed;
           ^

and

/home/aleksey/working/dotnet-runtime/src/libraries/Native/Unix/System.Native/pal_process.c(374,92): error G8B626BD7: cast from 'void (*)(int, siginfo_t *, void *)' to 'void (*)(int)' converts to incompatible function type [-Werror,-Wcast-function-type] [/home/aleksey/working/dotnet-runtime/src/libraries/Native/build-native.proj]
                  void (*oldhandler)(int) = (((unsigned int)sa_old.sa_flags) & SA_SIGINFO) ? (void (*)(int))sa_old.sa_sigaction : sa_old.sa_handler;
                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Oct 13, 2021
@ghost
Copy link

ghost commented Oct 13, 2021

Tagging subscribers to this area: @Anipik, @safern, @ViktorHofer
See info in area-owners.md if you want to be subscribed.

Issue Details

Repro:

  1. Install clang-13 and libicu-dev (I have 67.1-7 on Debian testing)
  2. Compile the native library code.

Expected result: Build succeeds

Actual result: build fails with

/home/aleksey/working/dotnet-runtime/src/libraries/Native/Unix/System.Globalization.Native/pal_casing.c(47,13): error G57817EDC: identifier '__c2' is reserved because it starts with '__' [-Werror,-Wreserved-identifier] [/home/aleksey/working/dotnet-runtime/src/libraries/Native/build-native.proj]
              U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
              ^
  /usr/include/unicode/utf16.h:311:18: note: expanded from macro 'U16_NEXT'
          uint16_t __c2; \
                   ^

This is happening because -Weverything includes the new -Wreserved-identifier warning (more here)

add_compile_options(-Weverything)


At least ICU and openssl are affected.

Author: lambdageek
Assignees: -
Labels:

area-Infrastructure-libraries, untriaged

Milestone: -

@lambdageek
Copy link
Member Author

/cc @steveisok @akoeplinger

@lambdageek
Copy link
Member Author

lambdageek commented Oct 13, 2021

One option is to pass -Wno-reserved-identifier, except I don't know how to check if clang is new enough

So we'd have to do something like (unless cmake somehow filters out unknown options?)

add_compile_options(-Wno-error=unknown-warning-option -Wno-reserved-identifier)

@lambdageek
Copy link
Member Author

ah -Wcast-function-type was in GCC 8, but it's new in clang-13 (llvm/llvm-project@217f0f7)

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Oct 13, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Oct 13, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure-libraries untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant