Skip to content

Conversation

@JongHeonChoi
Copy link
Contributor

An error occurred during cross-build on my Linux machine as shown below.

#> ROOTFS_DIR=/home/choi/dotnet/runtime/.tools/rootfs/arm64/ ./build.sh -c Debug -arch arm64 -s clr+libs+packs -cross

  crossgen2 -> /home/choi/dotnet/runtime/artifacts/bin/coreclr/Linux.arm64.Debug/crossgen2/linux-arm64/crossgen2.dll
/home/choi/dotnet/runtime/artifacts/bin/coreclr/Linux.arm64.Debug/build/Microsoft.NETCore.Native.Unix.targets(149,5): error : Requested linker ('clang-9') not found in PATH. [/home/choi/dotnet/runtime/src/coreclr/tools/aot/crossgen2/crossgen2.csproj]

Build FAILED.

/home/choi/dotnet/runtime/artifacts/bin/coreclr/Linux.arm64.Debug/build/Microsoft.NETCore.Native.Unix.targets(149,5): error : Requested linker ('clang-9') not found in PATH. [/home/choi/dotnet/runtime/src/coreclr/tools/aot/crossgen2/crossgen2.csproj]
    0 Warning(s)
    1 Error(s)

So, I don't think we need to fix the version of clang.

@ghost ghost added community-contribution Indicates that the PR has been added by a community member area-crossgen2-coreclr labels Oct 20, 2022
@am11
Copy link
Member

am11 commented Oct 20, 2022

The problem is with some of the CI images don't have version-less clang in PATH, so we need to specify the version. This happens when we install clang via llvm.sh or via package manager on OS where clang-9 is not default (some newer version is available).

There are two ways to fix it:

  1. Quick way: append these conditions with '$(CppCompilerAndLinker)' == '' (i.e. if it is not set, then set it.. so we can override). Then use ./build.sh -clang or -clang15 or --clang-14 (whichever version you are using). This is already handled in eng/build.sh where we pass CppCompilerAndLinker when user specifies the compiler.
  2. The "proper" way: we have a battle-tested script coming from arcade at eng/common/native/init-compiler.sh and used by multiple repos. We can invoke that in targets to compute this property. It has all kinds of old/new clang/gcc versions handled. We use it in number of places for rest of the native build:
    • <Exec Command="bash -c 'source &quot;$(RepositoryEngineeringDir)/common/native/init-compiler.sh&quot; &quot;$(RepositoryEngineeringDir)/common/native&quot; $(TargetArchitecture) $(NativeCompiler) &amp;&amp; echo $CC' 2>/dev/null"
    • <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' != 'windows'">bash -c 'source $(RepositoryEngineeringCommonDir)native/init-compiler.sh &quot;$(RepositoryEngineeringCommonDir)native&quot; &quot;$(_CompilerTargetArch)&quot; &quot;$(MonoCCompiler)&quot; &amp;&amp; @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
    • source "$nativescriptroot/init-compiler.sh" "$nativescriptroot" "$host_arch" "$compiler"

With option 2, we can include it in the NativeAOT's ILCompiler nuget package (as we include it in Microsoft.DotNet.CMake.Sdk nuget package). That way we don't even need to set CppCompilerAndLinker in eng/testing/tests.singlefile.targets and src/coreclr/tools/aot/crossgen2/crossgen2.csproj.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-crossgen2-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants