dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.42k stars 199 forks source link

NativeAOT-LLVM: For the msbuild exec task, don't assume a working directory #2334

Closed yowl closed 1 year ago

yowl commented 1 year ago

This PR uses an absolute path for the clang++ args as the working directory cannot be assumed.

I was using MSBuild executable path = "C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\MSBuild.dll" and a local package directory, i.e. nuget.config like

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value=".packages" />
  </config>

And I observed from dotnet publish -r wasi-wasm -c Release /p:MSBuildEnableWorkloadResolver=false --self-contained /p:UseAppHost=false /bl that the clang++ command was failing with, for example:

clang++ : error : no such file or directory: 'obj\Release\net8.0\wasi-wasm\native\cswasi.external.bc' [E:\GitHub\cs-wit
-bindgen\.packages\microsoft.dotnet.ilcompiler.llvm\8.0.0-preview.7.23354.2\build\ExecWrapper.proj]
clang++ : error : no input files [E:\GitHub\cs-wit-bindgen\.packages\microsoft.dotnet.ilcompiler.llvm\8.0.0-preview.7.2
3354.2\build\ExecWrapper.proj]

The input files were present, but adding dir && .... to the exec command revealed the current working directory was

Directory of E:\GitHub\cs-wit-bindgen\.packages\microsoft.dotnet.ilcompiler.llvm\8.0.0-preview.7.23354.2\build