Skip to content

Install clang in codespace for NativeAOT builds#55291

Open
marcpopMSFT wants to merge 2 commits into
mainfrom
marcpopmsft-fix-codespace-clang-for-aot
Open

Install clang in codespace for NativeAOT builds#55291
marcpopMSFT wants to merge 2 commits into
mainfrom
marcpopmsft-fix-codespace-clang-for-aot

Conversation

@marcpopMSFT

Copy link
Copy Markdown
Member

Summary

The devcontainer base Debian image (mcr.microsoft.com/devcontainers/base:debian) doesn't include clang, which is required by the dotnet-aot NativeAOT component build. Without it, the build fails with:

EXEC : error No compatible version of clang was found within the range of 8 to 23.
Please upgrade your toolchain or specify the compiler explicitly using CLR_CC and CLR_CXX environment variables.

Changes

Adds the LLVM apt repository and installs clang-18 in the devcontainer post-creation script, before restore/build runs. The script sources /etc/os-release for the Debian codename so it adapts automatically if the base image version changes.

Testing

Verified manually on a codespace that the install succeeds and the AOT build completes.

The devcontainer base Debian image doesn't ship clang, which is required
by the dotnet-aot NativeAOT component build. Add the LLVM apt repository
and install clang-18 in the post-creation script.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 15, 2026 00:08
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds LLVM/clang tooling to the Codespaces devcontainer so NativeAOT (dotnet-aot) builds can succeed on the base Debian image.

Changes:

  • Adds the LLVM apt repository during devcontainer post-create.
  • Installs clang-18 before running repo restore/build steps.

Comment thread .devcontainer/scripts/post-creation.sh Outdated
Comment on lines +5 to +8
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc > /dev/null
. /etc/os-release
echo "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-18 main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update && sudo apt-get install -y clang-18
Comment thread .devcontainer/scripts/post-creation.sh Outdated
Comment on lines +3 to +8
# Install clang (required for NativeAOT/dotnet-aot builds)
# The base Debian image doesn't include LLVM packages, so add the LLVM apt repository
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc > /dev/null
. /etc/os-release
echo "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-18 main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update && sudo apt-get install -y clang-18

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't do this. Just pick a different base image. Switch to Ubuntu Noble or Resolute as the devcontainer base image instead of Debian.

Also, you don't need clang. All you need is gcc and zlib. See https://github.com/dotnet/dotnet-docker/blob/cbbef15bee70061b529b71a91f072dbe36fa3ddb/src/sdk/11.0/resolute-aot/amd64/Dockerfile#L6-L7

Per review feedback, switch the base image from Debian to Ubuntu and
install only gcc + zlib1g-dev (not clang) for NativeAOT builds, matching
the dotnet-docker AOT SDK image approach.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants