Skip to content

Commit 97669b0

Browse files
Add compiler flags for clang-21. (#120775)
In clang-20 there is a known breaking change to `-fwrapv` that impacted us. Details can be found at https://releases.llvm.org/20.1.0/tools/clang/docs/ReleaseNotes.html#potentially-breaking-changes. Add the `-fno-strict-aliasing` to match our MSVC usage as well. Contributes to #119706 --------- Co-authored-by: Jan Kotas <[email protected]>
1 parent c04e15f commit 97669b0

File tree

6 files changed

+47
-41
lines changed

6 files changed

+47
-41
lines changed

docs/workflow/using-docker.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ The main Docker images are the most commonly used ones, and the ones you will pr
2626

2727
| Host OS | Target OS | Target Arch | Image | crossrootfs dir |
2828
| ----------------- | ------------ | --------------- | -------------------------------------------------------------------------------------- | -------------------- |
29-
| Azure Linux (x64) | Alpine 3.17 | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64-musl` | `/crossrootfs/x64` |
30-
| Azure Linux (x64) | Ubuntu 18.04 | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64` | `/crossrootfs/x64` |
31-
| Azure Linux (x64) | Alpine 3.17 | Arm32 (armhf) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm-musl` | `/crossrootfs/arm` |
32-
| Azure Linux (x64) | Ubuntu 22.04 | Arm32 (armhf) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm` | `/crossrootfs/arm` |
33-
| Azure Linux (x64) | Alpine 3.17 | Arm64 (arm64v8) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm64-musl` | `/crossrootfs/arm64` |
34-
| Azure Linux (x64) | Ubuntu 18.04 | Arm64 (arm64v8) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm64` | `/crossrootfs/arm64` |
35-
| Azure Linux (x64) | Ubuntu 18.04 | x86 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-x86` | `/crossrootfs/x86` |
29+
| Azure Linux (x64) | Alpine 3.17 | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-amd64-musl` | `/crossrootfs/x64` |
30+
| Azure Linux (x64) | Ubuntu 18.04 | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-amd64` | `/crossrootfs/x64` |
31+
| Azure Linux (x64) | Alpine 3.17 | Arm32 (armhf) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm-musl` | `/crossrootfs/arm` |
32+
| Azure Linux (x64) | Ubuntu 22.04 | Arm32 (armhf) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm` | `/crossrootfs/arm` |
33+
| Azure Linux (x64) | Alpine 3.17 | Arm64 (arm64v8) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm64-musl` | `/crossrootfs/arm64` |
34+
| Azure Linux (x64) | Ubuntu 18.04 | Arm64 (arm64v8) | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm64` | `/crossrootfs/arm64` |
35+
| Azure Linux (x64) | Ubuntu 18.04 | x86 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-x86` | `/crossrootfs/x86` |
3636

3737
**Extended Docker Images**
3838

3939
| Host OS | Target OS | Target Arch | Image | crossrootfs dir |
4040
| ----------------- | -------------------------- | ------------- | --------------------------------------------------------------------------------------- | ---------------------- |
41-
| Azure Linux (x64) | Android Bionic | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-android-amd64` | *N/A* |
42-
| Azure Linux (x64) | Android Bionic (w/OpenSSL) | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-android-openssl` | *N/A* |
43-
| Azure Linux (x64) | Android Bionic (w/Docker) | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-android-docker` | *N/A* |
44-
| Azure Linux (x64) | FreeBSD 14 | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-freebsd-14` | `/crossrootfs/x64` |
45-
| Azure Linux (x64) | Ubuntu 18.04 | PPC64le | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-ppc64le` | `/crossrootfs/ppc64le` |
46-
| Azure Linux (x64) | Ubuntu 24.04 | RISC-V | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-riscv64` | `/crossrootfs/riscv64` |
47-
| Azure Linux (x64) | Debian sid | LoongArch | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-loongarch64` | `/crossrootfs/loongarch64` |
48-
| Azure Linux (x64) | Ubuntu 18.04 | S390x | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-s390x` | `/crossrootfs/s390x` |
49-
| Azure Linux (x64) | Ubuntu 18.04 (Wasm) | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-webassembly-amd64` | `/crossrootfs/x64` |
41+
| Azure Linux (x64) | Android Bionic | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-android-amd64` | *N/A* |
42+
| Azure Linux (x64) | Android Bionic (w/OpenSSL) | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-android-openssl` | *N/A* |
43+
| Azure Linux (x64) | Android Bionic (w/Docker) | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-android-docker` | *N/A* |
44+
| Azure Linux (x64) | FreeBSD 14 | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-freebsd-14` | `/crossrootfs/x64` |
45+
| Azure Linux (x64) | Ubuntu 18.04 | PPC64le | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-ppc64le` | `/crossrootfs/ppc64le` |
46+
| Azure Linux (x64) | Ubuntu 24.04 | RISC-V | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-riscv64` | `/crossrootfs/riscv64` |
47+
| Azure Linux (x64) | Debian sid | LoongArch | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-loongarch64` | `/crossrootfs/loongarch64` |
48+
| Azure Linux (x64) | Ubuntu 18.04 | S390x | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-s390x` | `/crossrootfs/s390x` |
49+
| Azure Linux (x64) | Ubuntu 18.04 (Wasm) | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-webassembly-amd64` | `/crossrootfs/x64` |
5050
| Debian (x64) | Debian 12 | x64 | `mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc15-amd64` | *N/A* |
5151
| Ubuntu (x64) | Tizen 9.0 | Arm32 (armel) | `mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-armel-tizen` | `/crossrootfs/armel` |
5252

@@ -59,7 +59,7 @@ docker run --rm \
5959
-v <RUNTIME_REPO_PATH>:/runtime \
6060
-w /runtime \
6161
-e ROOTFS_DIR=/crossrootfs/x64/ \
62-
mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64 \
62+
mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-amd64 \
6363
./build.sh -s clr --cross -c Checked
6464
```
6565

@@ -69,7 +69,7 @@ Now, dissecting the command:
6969
- `-v <RUNTIME_REPO_PATH>:/runtime`: Mount the runtime repo clone located in `<RUNTIME_REPO_PATH>` to the container path `/runtime`.
7070
- `-w /runtime`: Start the container in the `/runtime` directory.
7171
- `-e ROOTFS_DIR=/crossrootfs/x64/` sets up the environment variable for crossbuilding.
72-
- `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64`: The fully qualified name of the Docker image to download. In this case, we want to use an *Azure Linux* image to target the *x64* architecture.
72+
- `mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-amd64`: The fully qualified name of the Docker image to download. In this case, we want to use an *Azure Linux* image to target the *x64* architecture.
7373
- `./build.sh -s clr --cross -c Checked`: The build command to run in the repo. In this case, we want to build the *Clr* subset in the *Checked* configuration with the cross compilation option.
7474

7575
You might also want to interact with the container directly for a myriad of reasons, like running multiple builds in different paths for example. In this case, instead of passing the build script command to the `docker` command-line, pass the flag `-it`. When you do this, you will get access to a small shell within the container, which allows you to explore it, run builds manually, and so on, like you would on a regular terminal in your machine. Note that the containers' shell's built-in tools are very limited in comparison to the ones you probably have on your machine, so don't expect to be able to do full work there.

eng/native/configurecompiler.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,14 @@ if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI)
540540
# Disable frame pointer optimizations so profilers can get better call stacks
541541
add_compile_options(-fno-omit-frame-pointer)
542542

543-
# Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
543+
# Make signed overflow well-defined. Implies the following flags in clang-20 and above.
544+
# -fwrapv - Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
544545
# using twos-complement representation (this is normally undefined according to the C++ spec).
545-
add_compile_options(-fwrapv)
546+
# -fwrapv-pointer - The same as -fwrapv but for pointers.
547+
add_compile_options(-fno-strict-overflow)
548+
549+
# Suppress C++ strict aliasing rules. This matches our use of MSVC.
550+
add_compile_options(-fno-strict-aliasing)
546551

547552
if(CLR_CMAKE_HOST_APPLE)
548553
# Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand.

eng/pipelines/common/templates/pipeline-with-resources.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,49 @@ extends:
1717

1818
containers:
1919
linux_arm:
20-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm
20+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm
2121
env:
2222
ROOTFS_DIR: /crossrootfs/arm
2323

2424
linux_arm64:
25-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm64
25+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm64
2626
env:
2727
ROOTFS_DIR: /crossrootfs/arm64
2828

2929
linux_musl_x64:
30-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64-musl
30+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-amd64-musl
3131
env:
3232
ROOTFS_DIR: /crossrootfs/x64
3333

3434
linux_musl_arm:
35-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm-musl
35+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm-musl
3636
env:
3737
ROOTFS_DIR: /crossrootfs/arm
3838

3939
linux_musl_arm64:
40-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm64-musl
40+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-arm64-musl
4141
env:
4242
ROOTFS_DIR: /crossrootfs/arm64
4343

4444
# This container contains all required toolsets to build for Android and for Linux with bionic libc.
4545
android:
46-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-android-amd64
46+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-android-amd64
4747

4848
# This container contains all required toolsets to build for Android and for Linux with bionic libc and a special layout of OpenSSL.
4949
linux_bionic:
50-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-android-openssl-amd64
50+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-android-openssl-amd64
5151

5252
# This container contains all required toolsets to build for Android as well as tooling to build docker images.
5353
android_docker:
54-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-android-docker-amd64
54+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-android-docker-amd64
5555

5656
linux_x64:
57-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64
57+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-amd64
5858
env:
5959
ROOTFS_DIR: /crossrootfs/x64
6060

6161
linux_x86:
62-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-x86
62+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-x86
6363
env:
6464
ROOTFS_DIR: /crossrootfs/x86
6565

@@ -70,7 +70,7 @@ extends:
7070
image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.22-amd64
7171

7272
linux_x64_sanitizer:
73-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64-sanitizer
73+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-amd64-sanitizer
7474
env:
7575
ROOTFS_DIR: /crossrootfs/x64
7676

@@ -83,22 +83,22 @@ extends:
8383
image: mcr.microsoft.com/dotnet-buildtools/prereqs:almalinux-9-source-build-amd64
8484

8585
linux_s390x:
86-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-s390x
86+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-s390x
8787
env:
8888
ROOTFS_DIR: /crossrootfs/s390x
8989

9090
linux_ppc64le:
91-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-ppc64le
91+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-ppc64le
9292
env:
9393
ROOTFS_DIR: /crossrootfs/ppc64le
9494

9595
linux_riscv64:
96-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-riscv64
96+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-riscv64
9797
env:
9898
ROOTFS_DIR: /crossrootfs/riscv64
9999

100100
linux_loongarch64:
101-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-loongarch64
101+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-loongarch64
102102
env:
103103
ROOTFS_DIR: /crossrootfs/loongarch64
104104

@@ -109,17 +109,17 @@ extends:
109109
image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream-10-amd64
110110

111111
browser_wasm:
112-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-webassembly-amd64
112+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-webassembly-amd64
113113
env:
114114
ROOTFS_DIR: /crossrootfs/x64
115115

116116
wasi_wasm:
117-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-webassembly-amd64
117+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-webassembly-amd64
118118
env:
119119
ROOTFS_DIR: /crossrootfs/x64
120120

121121
freebsd_x64:
122-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-freebsd-14-amd64
122+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net11.0-cross-freebsd-14-amd64
123123
env:
124124
ROOTFS_DIR: /crossrootfs/x64
125125

src/native/libs/System.Native/pal_interfaceaddresses.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ int32_t SystemNative_EnumerateGatewayAddressesForInterface(void* context, uint32
561561
return -1;
562562
}
563563

564-
uint8_t* buffer = malloc(byteCount);
564+
uint8_t* buffer = (uint8_t*)malloc(byteCount);
565565
if (buffer == NULL)
566566
{
567567
errno = ENOMEM;
@@ -587,7 +587,7 @@ int32_t SystemNative_EnumerateGatewayAddressesForInterface(void* context, uint32
587587

588588
byteCount = tmpEstimatedSize;
589589
free(buffer);
590-
buffer = malloc(byteCount);
590+
buffer = (uint8_t*)malloc(byteCount);
591591
if (buffer == NULL)
592592
{
593593
errno = ENOMEM;

src/native/libs/System.Security.Cryptography.Native/opensslshim.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ extern TYPEOF(OPENSSL_gmtime)* OPENSSL_gmtime_ptr;
14631463
#define sk_X509_push(stack,value) OPENSSL_sk_push((OPENSSL_STACK*)(1 ? stack : (STACK_OF(X509)*)0), (const void*)(1 ? value : (X509*)0))
14641464

14651465
// type-safe OPENSSL_sk_pop
1466-
#define sk_X509_pop(stack) OPENSSL_sk_pop((OPENSSL_STACK*)(1 ? stack : (STACK_OF(X509)*)0))
1466+
#define sk_X509_pop(stack) ((X509*)OPENSSL_sk_pop((OPENSSL_STACK*)(1 ? stack : (STACK_OF(X509)*)0)))
14671467

14681468
// type-safe OPENSSL_sk_pop_free
14691469
#define sk_X509_pop_free(stack, freefunc) OPENSSL_sk_pop_free((OPENSSL_STACK*)(1 ? stack : (STACK_OF(X509)*)0), (OPENSSL_sk_freefunc)(1 ? freefunc : (sk_X509_freefunc)0))

src/native/libs/System.Security.Cryptography.Native/pal_x509.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ static int32_t X509ChainVerifyOcsp(X509_STORE_CTX* storeCtx, X509* subject, X509
12501250
{
12511251
#pragma clang diagnostic push
12521252
#pragma clang diagnostic ignored "-Wcast-qual"
1253+
#pragma clang diagnostic ignored "-Wimplicit-void-ptr-cast"
12531254
if (i2d_OCSP_RESPONSE_bio(bio, resp))
12541255
#pragma clang diagnostic pop
12551256
{

0 commit comments

Comments
 (0)