sec / dotnet-core-freebsd-source-build

Collection of script to build .NET Core under FreeBSD OS (with binary releases)
MIT License
53 stars 4 forks source link

[runtime/mono]Possible incorrect PKG_CONFIG_PATH when crossbuilding dotNET for ARM64 #19

Closed Thefrank closed 1 year ago

Thefrank commented 1 year ago

TL;DR: Title + file in question: https://github.com/dotnet/runtime/blob/fe95ddbe92a298eab2e56ed10e7d6e92c9bb5f0a/src/mono/mono.proj

While building the net8p2 SDK under Linux x86_64 for FreeBSD ARM64 I noticed runtime's build scripts passed two sets of vars to cmake during the mono leg:

TARGET_BUILD_ARCH=arm64 PKG_CONFIG_PATH=/crossrootfs/arm64/usr/lib/aarch64-linux-gnu/pkgconfig 
TARGET_BUILD_ARCH=arm64 PKG_CONFIG_PATH=/crossrootfs/arm64usr/local/libdata/pkgconfig

Both appear incorrect. The first would be fine going Linux x86_64 -> Linux ARM64 using either GCC or Clang. The second would always be incorrect as it appears to be missing a /. Oddly enough this does not cause build failures [possible CMake cache (mis)use? paths hardcoded elsewhere?]. Stranger still, FreeBSD x86_64 is the only one to not use an additional PKG_CONFIG_PATH for this leg.

coreclr is not impacted as it uses a "ROOTFS_DIR" that is passed as a part of the initial build.


now that runtime has a much better system setup for crossbuilding on to different platforms it might be worth taking a look to see if any FreeBSD hardcoded cases can be abstracted. I should have time to grep around and make any changes soonish

sec commented 1 year ago

Isn't this setup later https://github.com/dotnet/runtime/blob/fe95ddbe92a298eab2e56ed10e7d6e92c9bb5f0a/src/mono/mono.proj#L348 ?

ps. I'm doing native arm64 builds just to be on the same side :)

Thefrank commented 1 year ago

Isn't this setup later https://github.com/dotnet/runtime/blob/fe95ddbe92a298eab2e56ed10e7d6e92c9bb5f0a/src/mono/mono.proj#L348 ?

Yes. That exact line is where the possible error is as $(MonoCrossDir) returns something like /my/path.

sec commented 1 year ago

Weird enough, I remeber that builds were failing without that, so now it's maybe not even needed? :D

Thefrank commented 1 year ago

ah! it is a one character typo: https://github.com/dotnet/runtime/blob/fe95ddbe92a298eab2e56ed10e7d6e92c9bb5f0a/src/mono/mono.proj#L348 <_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)usr/local/libdata/pkgconfig" /> wrong <_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/usr/local/libdata/pkgconfig" /> right -------------------------------------------------------^

Thefrank commented 1 year ago

Closing. Making an upstream PR to fix.

sec commented 1 year ago

Thanks, I guess :D