Skip to content

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

Closed

Description

@lambdageek

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;
                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Activity

  1. ghost added
    untriaged
    on Oct 13, 2021
  2. lambdageek commented on Oct 13, 2021

    @lambdageek
    MemberAuthor
  3. lambdageek commented on Oct 13, 2021

    @lambdageek
    MemberAuthor

    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)
  4. lambdageek commented on Oct 13, 2021

    @lambdageek
    MemberAuthor

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

  5. ghost added
    in-pr
    on Oct 13, 2021
  6. ghost removed
    in-pr
    on Oct 13, 2021
  7. ghost locked as resolved and limited conversation to collaborators on Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Infrastructure-librariesuntriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions