runtime: Build of coreclr fails with musl 1.2.3

Description

Build of coreclr fails with musl 1.2.3 due to following error:

      [ 14%] Building C object Native.Unix/System.Security.Cryptography.Native/CMakeFiles/objlib.dir/pal_x509_root.c.o
      /home/buildozer/aports/community/dotnet6-stage0/src/source-build-tarball-6.0.102/src/runtime.839cdfb0ecca5e0be3dbccd926e7651ef50fdf10/artifacts/source-build/self/src/src/coreclr/pal/src/init/pal.cpp:350:24: error: no matching function for call to 'InterlockedCompareExchangePointerT'
                  if(NULL != InterlockedCompareExchangePointer(&init_critsec, &temp_critsec, NULL))
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /home/buildozer/aports/community/dotnet6-stage0/src/source-build-tarball-6.0.102/src/runtime.839cdfb0ecca5e0be3dbccd926e7651ef50fdf10/artifacts/source-build/self/src/src/coreclr/pal/src/include/pal/palinternal.h:727:43: note: expanded from macro 'InterlockedCompareExchangePointer'
      #define InterlockedCompareExchangePointer InterlockedCompareExchangePointerT
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /home/buildozer/aports/community/dotnet6-stage0/src/source-build-tarball-6.0.102/src/runtime.839cdfb0ecca5e0be3dbccd926e7651ef50fdf10/artifacts/source-build/self/src/src/coreclr/pal/src/include/pal/palinternal.h:715:11: note: candidate function template not viable: no known conversion from 'nullptr_t' to 'int' for 3rd argument
      inline T* InterlockedCompareExchangePointerT(
                ^
      /home/buildozer/aports/community/dotnet6-stage0/src/source-build-tarball-6.0.102/src/runtime.839cdfb0ecca5e0be3dbccd926e7651ef50fdf10/artifacts/source-build/self/src/src/coreclr/pal/src/include/pal/palinternal.h:684:4: note: candidate template ignored: could not match 'T *' against 'nullptr_t'
      T* InterlockedCompareExchangePointerT(
         ^
      /home/buildozer/aports/community/dotnet6-stage0/src/source-build-tarball-6.0.102/src/runtime.839cdfb0ecca5e0be3dbccd926e7651ef50fdf10/artifacts/source-build/self/src/src/coreclr/pal/src/include/pal/palinternal.h:705:11: note: candidate template ignored: could not match 'T *' against 'nullptr_t'
      inline T* InterlockedCompareExchangePointerT(
                ^
      1 error generated.

Caused by the following change in musl: https://git.musl-libc.org/cgit/musl/commit?id=98e688a9da5e7b2925dda17a2d6820dddf1fb287

Reproduction Steps

  1. Setup Alpine Edge environment with musl 1.2.3.
  2. Attempt a build

Expected behavior

Build should pass, as with musl 1.2.2

Actual behavior

Failure, as described in description.

Regression?

No response

Known Workarounds

Removing the problematic commit from musl does the trick.

Configuration

Alpine Edge Musl 1.2.3 installer version 6.0.102 with runtime 6.0.2 (as problematic files havn’t changed between 6.0.2 and 6.0.3, this issue should exist with current version)

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

-    return InterlockedCompareExchangePointerT(destination, reinterpret_cast<T*>(exchange), comparand);
+    return InterlockedCompareExchangePointerT(destination, comparand);

you are accidentally dropping an argument here

the fix is to change the int arguments to std::nullptr_t (or decltype(nullptr)); that way it will resolve the ambiguity and still allow taking both explicit NULL and nullptr constants