Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ function (get_symbol_file_name targetName outputSymbolFilename)
endif ()

set(${outputSymbolFilename} ${strip_destination_file} PARENT_SCOPE)
else(CLR_CMAKE_HOST_UNIX)
elseif(CLR_CMAKE_HOST_WIN32)
# We can't use the $<TARGET_PDB_FILE> generator expression here since
# the generator expression isn't supported on resource DLLs.
set(${outputSymbolFilename} $<TARGET_FILE_DIR:${targetName}>/$<TARGET_FILE_PREFIX:${targetName}>$<TARGET_FILE_BASE_NAME:${targetName}>.pdb PARENT_SCOPE)
endif(CLR_CMAKE_HOST_UNIX)
endif()
endfunction()

function(strip_symbols targetName outputFilename)
Expand Down Expand Up @@ -443,7 +443,9 @@ endfunction()
function(install_with_stripped_symbols targetName kind destination)
if(NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
strip_symbols(${targetName} symbol_file)
install_symbol_file(${symbol_file} ${destination} ${ARGN})
if (NOT "${symbol_file}" STREQUAL "")
install_symbol_file(${symbol_file} ${destination} ${ARGN})
endif()
endif()

if (CLR_CMAKE_TARGET_APPLE AND ("${kind}" STREQUAL "TARGETS"))
Expand Down
1 change: 1 addition & 0 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project(mono)

include(../../eng/native/configurepaths.cmake)
include(${CLR_ENG_NATIVE_DIR}/functions.cmake)
include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)

if (MSVC)
# Also set by configurecompiler.cmake, which isn't used by mono yet
Expand Down
2 changes: 1 addition & 1 deletion src/mono/dlls/dbgshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ if(CLR_CMAKE_HOST_UNIX)
endif()

target_link_libraries(dbgshim PRIVATE ${DBGSHIM_LIBRARIES} monoapi)
install(TARGETS dbgshim DESTINATION lib)
install_with_stripped_symbols(dbgshim TARGETS lib)
2 changes: 1 addition & 1 deletion src/mono/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,4 @@ if(CLR_CMAKE_HOST_UNIX)
endif()

target_link_libraries(mscordbi PRIVATE ${COREDBI_LIBRARIES} monoapi)
install(TARGETS mscordbi DESTINATION lib)
install_with_stripped_symbols(mscordbi TARGETS lib)
91 changes: 25 additions & 66 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
<_MonoCMakeArgs Include="-DCMAKE_INSTALL_PREFIX=&quot;$(MonoObjDir.Replace('\','/'))out&quot;"/>
<_MonoCMakeArgs Include="-DCMAKE_INSTALL_LIBDIR=lib"/>
<_MonoCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
<_MonoCMakeArgs Include="-DCLR_CMAKE_KEEP_NATIVE_SYMBOLS=true" Condition="'$(KeepNativeSymbols)' == 'true'" />
<_MonoCMakeArgs Condition="'$(CMakeArgs)' != ''" Include="$(CMakeArgs)"/>
<_MonoCMakeArgs Condition="'$(MonoEnableLLVM)' == 'true'" Include="-DLLVM_PREFIX=$(MonoLLVMDir)\$(_MonoLLVMTargetArchitecture)" />
<_MonoCMakeArgs Condition="'$(BuildDarwinFrameworks)' == 'true'" Include="-DBUILD_DARWIN_FRAMEWORKS=1" />
Expand Down Expand Up @@ -461,20 +462,19 @@
<PropertyGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">
<_IcuLibdir>$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)/native/lib</_IcuLibdir>
</PropertyGroup>
<ItemGroup Condition="('$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true') and '$(Platform)' == 'arm64'">
<_MonoCMakeArgs Include="-DCMAKE_OSX_ARCHITECTURES=arm64"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
<_MonoCMakeArgs Include="-DCMAKE_SYSTEM_NAME=$(_MonoCMakeSystemName)"/>
<_MonoCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(_MonoCMakeVersionMin)" />
<_MonoCMakeArgs Include="-DCMAKE_OSX_SYSROOT='$(_MonoCMakeSysroot)'" />
<_MonoCMakeArgs Condition="'$(Platform)' == 'x64'" Include="-DCMAKE_OSX_ARCHITECTURES=x86_64"/>
<_MonoCMakeArgs Condition="'$(Platform)' == 'x86'" Include="-DCMAKE_OSX_ARCHITECTURES=i386"/>
<_MonoCMakeArgs Condition="'$(Platform)' == 'arm64'" Include="-DCMAKE_OSX_ARCHITECTURES=arm64"/>
<_MonoCMakeArgs Condition="'$(Platform)' == 'arm'" Include="&quot;-DCMAKE_OSX_ARCHITECTURES=armv7%3Barmv7s&quot;"/>
<_MonoCFLAGS Include="-Wl,-application_extension" />
<_MonoCXXFLAGS Include="-Wl,-application_extension" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<_MonoCMakeArgs Condition="'$(Platform)' == 'x64'" Include="-DCMAKE_OSX_ARCHITECTURES=x86_64" />
<_MonoCMakeArgs Condition="'$(Platform)' == 'x86'" Include="-DCMAKE_OSX_ARCHITECTURES=i386" />
<_MonoCMakeArgs Condition="'$(Platform)' == 'arm64'" Include="-DCMAKE_OSX_ARCHITECTURES=arm64" />
<_MonoCMakeArgs Condition="'$(Platform)' == 'arm'" Include="&quot;-DCMAKE_OSX_ARCHITECTURES=armv7%3Barmv7s&quot;" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">
<_MonoCMakeArgs Include="-DICU_LIBDIR=$(_IcuLibdir)"/>
<_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/>
Expand Down Expand Up @@ -581,6 +581,8 @@
</ItemGroup>
<ItemGroup>
<_MonoCMakeArgs Include="-DMONO_COMPONENTS_RID=$(TargetOS)-$(TargetArchitecture)" />
<_MonoCMakeArgs Condition="'$(TargetArchitecture)' == 'wasm'" Include="-DCLR_CMAKE_HOST_ARCH=$(BuildArchitecture)" />
<_MonoCMakeArgs Condition="'$(TargetArchitecture)' != 'wasm'" Include="-DCLR_CMAKE_HOST_ARCH=$(TargetArchitecture)" />
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment explaining why we have this difference?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a comment. It is the case until we completely switch mono to use the common infra.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, but it is still not really clear to me why this is different on wasm vs. non-wasm?

Copy link
Member Author

@am11 am11 Apr 13, 2023

Choose a reason for hiding this comment

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

I copied this existing condition from this same file. There is no comment on line 769 either. Without this, wasm builds fail. So the comment I've added is based on my understanding of the situation. I'm sure there is a better way to elaborate it, but depending on the audience, I guess it will still fall short until we explain everything. 😅

Wasm is always cross-compiled; meaning host is always different than target. But when we add build dimension; i.e. we are in our other cross-compiling environment (e.g. linux-x64 (the system running build.sh) -> linux-arm64 (for which the cross/aot tools are compiled in stage0) -> wasm (the target emitted by those cross/aot tools in stage 1)) then host != target != build holds and it fails wasm builds without this flip.

In coreclr, tools like crossgen2 are built for multi-tagets, so we can do things like crossgen2 --targetarch arm64 on x64 machine. That cuts off the requirement of dealing with the third dimension in build infra. I suppose mono cross/aot tools are not on such multi-target plan.

Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry I didn't realize this was existing code. Looks like this was added in 81724f1.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey 81724f1 is some of my best work!

</ItemGroup>

<PropertyGroup>
Expand Down Expand Up @@ -633,55 +635,6 @@
<!-- build -->
<Message Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Text="Running '$(_MonoCMakeBuildCommand)' in '$(MonoObjDir)'" Importance="High"/>
<Exec Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Command="$(_MonoCMakeBuildCommand)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)"/>

<!-- strip -->
<PropertyGroup>
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">darwin-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="'$(HostOS)' == 'windows'">windows-x86_64</MonoToolchainPrebuiltOS>
<_MonoRuntimeFilePath>$(MonoObjDir)out\lib\$(MonoFileName)</_MonoRuntimeFilePath>
<_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(TargetsLinuxMusl)' != 'true'">linux-gnu</_LinuxAbi>
<_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(TargetsLinuxMusl)' == 'true'">alpine-linux-musl</_LinuxAbi>
<_LinuxAbi Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">linux-android</_LinuxAbi>
<_LinuxFloatAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">hf</_LinuxFloatAbi>
<_Objcopy>objcopy</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 'arm'">arm-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 'armv6'">arm-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 'arm64'">aarch64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 'riscv64'">riscv64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 's390x'">s390x-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 'ppc64le'">powerpc64le-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 'x64'">x86_64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(Platform)' == 'x86'">i686-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/llvm-objcopy</_Objcopy>
<_Objcopy Condition="'$(TargetsLinuxMusl)' == 'true' and '$(CrossBuild)' != 'true'">objcopy</_Objcopy>

<_ObjcopyPrefix Condition="'$(MonoCrossDir)' != '' and '$(Platform)' == 'riscv64' and $(_Objcopy) == ''">llvm-objcopy-</_ObjcopyPrefix>
</PropertyGroup>
<!-- test viability of objcopy command -->
<Exec Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsLinux)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true')" Command="$(_Objcopy) -V" IgnoreStandardErrorWarningFormat="true" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" EchoOff="true" ConsoleToMsBuild="true">
<Output TaskParameter="ExitCode" PropertyName="_ObjcopyFound"/>
</Exec>
<Exec Condition="'$(_ObjcopyPrefix)' != ''" Command="find /usr/bin -name $(_ObjcopyPrefix)* | sort -V | tail -1" IgnoreStandardErrorWarningFormat="true" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" EchoOff="true" ConsoleToMsBuild="true">
<Output TaskParameter="ExitCode" PropertyName="_ObjcopyFound"/>
<Output TaskParameter="ConsoleOutput" PropertyName="_Objcopy"/>
</Exec>

<PropertyGroup>
<!-- if all else fails in finding a valid objcopy, fall back to no-prefix from $PATH (used for x64 on CentOS) -->
<_Objcopy Condition="'$(_ObjcopyFound)' != '0'">objcopy</_Objcopy>
</PropertyGroup>
<ItemGroup Condition="'$(KeepNativeSymbols)' != 'true'" >
<FilesToStrip Include="$(_MonoRuntimeFilePath)" />
<FilesToStrip Include="$([System.IO.Directory]::GetParent($(_MonoRuntimeFilePath)))\libmono-component-*$(LibSuffix)" />
<FilesToStrip Include="$([System.IO.Directory]::GetParent($(_MonoRuntimeFilePath)))\Mono*framework\**\Mono*" Exclude="$([System.IO.Directory]::GetParent($(_MonoRuntimeFilePath)))\Mono*framework\**\*.dwarf" />
</ItemGroup>
<Message Condition="'@(FilesToStrip)' != '' and '$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ($([MSBuild]::IsOSPlatform('OSX')) or $([MSBuild]::IsOSPlatform('Linux')))" Text="Stripping debug symbols from %(FilesToStrip.Identity)" Importance="High"/>
<Exec Condition="'@(FilesToStrip)' != '' and !$([System.String]::Copy(%(FilesToStrip.Identity)).EndsWith('.a')) and '$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true')" Command="dsymutil --flat --minimize %(FilesToStrip.Identity)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)"/>
<Exec Condition="'@(FilesToStrip)' != '' and !$([System.String]::Copy(%(FilesToStrip.Identity)).EndsWith('.a')) and '$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true') and '$(Configuration)' == 'Release'" Command="strip -no_code_signature_warning -S %(FilesToStrip.Identity)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)"/>
<Exec Condition="'@(FilesToStrip)' != '' and !$([System.String]::Copy(%(FilesToStrip.Identity)).EndsWith('.a')) and '$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsLinux)' == 'true' or '$(TargetsAndroid)' == 'true')" Command="$(_Objcopy) --only-keep-debug %(FilesToStrip.Identity) %(FilesToStrip.Identity).dbg" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)"/>
<Exec Condition="'@(FilesToStrip)' != '' and !$([System.String]::Copy(%(FilesToStrip.Identity)).EndsWith('.a')) and '$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsLinux)' == 'true' or '$(TargetsAndroid)' == 'true')" Command="$(_Objcopy) --strip-unneeded %(FilesToStrip.Identity)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)"/>
<Exec Condition="'@(FilesToStrip)' != '' and !$([System.String]::Copy(%(FilesToStrip.Identity)).EndsWith('.a')) and '$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsLinux)' == 'true' or '$(TargetsAndroid)' == 'true')" Command="$(_Objcopy) --add-gnu-debuglink=%(FilesToStrip.Identity).dbg %(FilesToStrip.Identity)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)"/>
</Target>

<!-- Build AOT cross compiler (if available) -->
Expand Down Expand Up @@ -712,6 +665,12 @@
<MonoAotAbi Condition="'$(Platform)' == 'x64'">x86_64-apple-maccatalyst</MonoAotAbi>
</PropertyGroup>

<PropertyGroup>
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">darwin-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="'$(HostOS)' == 'windows'">windows-x86_64</MonoToolchainPrebuiltOS>
</PropertyGroup>

<!-- Linux specific options -->
<ItemGroup Condition="'$(RealTargetOS)' == 'linux' or $([MSBuild]::IsOSPlatform('Linux'))">
<_LibClang Include="$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/lib64/libclang.so.*"/>
Expand All @@ -724,9 +683,15 @@
<MonoAotOffsetsPrefix Condition="'$(Platform)' == 'arm64'">$(MonoCrossDir)/usr/lib/gcc/aarch64-linux-gnu/5</MonoAotOffsetsPrefix>
</PropertyGroup>

<PropertyGroup>
<_MonoLLVMTargetArchitecture>$(BuildArchitecture)</_MonoLLVMTargetArchitecture>
<_MonoLLVMTargetArchitecture Condition="'$(RealTargetArchitecture)' != ''">$(RealTargetArchitecture)</_MonoLLVMTargetArchitecture>
</PropertyGroup>

<!-- macOS host specific options -->
<ItemGroup Condition="'$(RealTargetOS)' == 'osx' or $([MSBuild]::IsOSPlatform('OSX'))">
<MonoAOTCMakeArgs Condition="'$(RealTargetArchitecture)' == 'arm64'" Include="-DCMAKE_OSX_ARCHITECTURES=arm64"/>
<MonoAOTCMakeArgs Condition="'$(_MonoLLVMTargetArchitecture)' == 'x64'" Include="-DCMAKE_OSX_ARCHITECTURES=x86_64" />
<MonoAOTCMakeArgs Condition="'$(_MonoLLVMTargetArchitecture)' != 'x64'" Include="-DCMAKE_OSX_ARCHITECTURES=$(_MonoLLVMTargetArchitecture)" />
<MonoAOTCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(macOSVersionMin)" />
<MonoAOTCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/>
<_MonoAOTCFLAGS Condition="'$(RealTargetArchitecture)' == 'arm64'" Include="-arch arm64" />
Expand Down Expand Up @@ -773,6 +738,8 @@
<_MonoAOTCPPFLAGS Include="-DNVALGRIND" />

<MonoAOTCMakeArgs Include="-DDISABLE_INTERPRETER=1" />
<MonoAOTCMakeArgs Condition="'$(TargetArchitecture)' == 'wasm'" Include="-DCLR_CMAKE_HOST_ARCH=$(BuildArchitecture)" />
<MonoAOTCMakeArgs Condition="'$(TargetArchitecture)' != 'wasm'" Include="-DCLR_CMAKE_HOST_ARCH=$(TargetArchitecture)" />

<!-- Select generator platform for VS generator -->
<MonoAOTCMakeArgs Condition="'$(_MonoUseNinja)' != 'true' and '$(Platform)' == 'x64'" Include="-A x64" />
Expand All @@ -784,9 +751,6 @@
<!-- Android specific options -->
<PropertyGroup Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">
<_MonoSkipInitCompiler>true</_MonoSkipInitCompiler>
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">darwin-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="'$(HostOS)' == 'windows'">windows-x86_64</MonoToolchainPrebuiltOS>

<MonoUseCrossTool>true</MonoUseCrossTool>
<MonoAotCMakeSysroot Condition="Exists('$(ANDROID_NDK_ROOT)/sysroot')">$(ANDROID_NDK_ROOT)/sysroot</MonoAotCMakeSysroot>
Expand Down Expand Up @@ -828,8 +792,6 @@
<PropertyGroup>
<_MonoAOTCFLAGSOption>-DCMAKE_C_FLAGS=&quot;@(_MonoAOTCPPFLAGS, ' ') @(_MonoAOTCFLAGS, ' ')&quot;</_MonoAOTCFLAGSOption>
<_MonoAOTCXXFLAGSOption>-DCMAKE_CXX_FLAGS=&quot;@(_MonoAOTCPPFLAGS, ' ') @(_MonoAOTCXXFLAGS, ' ')&quot;</_MonoAOTCXXFLAGSOption>
<_MonoLLVMTargetArchitecture>$(BuildArchitecture)</_MonoLLVMTargetArchitecture>
<_MonoLLVMTargetArchitecture Condition="'$(RealTargetArchitecture)' != ''">$(RealTargetArchitecture)</_MonoLLVMTargetArchitecture>
</PropertyGroup>
<ItemGroup>
<MonoAOTCMakeArgs Include="-DAOT_TARGET_TRIPLE=$(MonoAotAbi)"/>
Expand Down Expand Up @@ -916,8 +878,7 @@
<!-- General targets -->
<Target Name="BuildMono" AfterTargets="Build" DependsOnTargets="$(MonoDependsOnTargets)">
<PropertyGroup Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true'">
<_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true'">$(MonoObjDir)out\bin\$(MonoFileName)</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)out\lib\$(MonoFileName)</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath>$(MonoObjDir)out\lib\$(MonoFileName)</_MonoRuntimeFilePath>
<_MonoRuntimeStaticFilePath Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(MonoObjDir)out\lib\$(MonoStaticLibFileName)</_MonoRuntimeStaticFilePath>
<_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true</_MonoIncludeInterpStaticFiles>
<_MonoIncludeIcuFiles Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">true</_MonoIncludeIcuFiles>
Expand Down Expand Up @@ -1069,8 +1030,6 @@
DestinationFiles="@(_MonoRuntimeBuildArtifacts->'$(RuntimeBinDir)build\%(RecursiveDir)%(Filename)%(Extension)')"
SkipUnchangedFiles="true"
Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true'" />

<Exec Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true' and '$(MonoGenerateOffsetsOSGroups)' == '' and ('$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true')" Command="install_name_tool -id @rpath/$(MonoFileName) $(RuntimeBinDir)$(MonoFileName)" />
Copy link
Member

Choose a reason for hiding this comment

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

did you verify that the rpath is correct after this change?

Copy link
Member

Choose a reason for hiding this comment

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

I confirmed this works because we pass -DMONO_SHARED_LIB_NAME=$(MonoSharedLibName) into cmake now so the filename is correct from the beginning (and thus the rpath).

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH, I mainly relied upon the CI for this one. We switched cmake install with our wrapper install_with_stripped_symbols, which is used for all binaries for coreclr, libs and corehost.

Now that you have mentioned it, I tested it on osx-arm64 and otool gives me the same output before (main) and after (PR):

$ ./build.sh mono -c Release

$ otool -l artifacts/bin/mono/osx.arm64.Release/libcoreclr.dylib
[...]
Load command 4
          cmd LC_ID_DYLIB
      cmdsize 48
         name @rpath/libcoreclr.dylib (offset 24)
   time stamp 1 Thu Jan  1 02:00:01 1970
      current version 2.0.0
[...]

If the passing CI legs do not indicate that iOS / other targets are in the clear and this testing (on osx-arm64) is not enough, I can try to build for those platforms as well?

Copy link
Member

Choose a reason for hiding this comment

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

I looked through the failures on runtime-extra-platforms and none of them seem to be related :)

</Target>

<Target Name="CleanMono">
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ if(NOT DISABLE_COMPONENTS AND NOT STATIC_COMPONENTS)
target_link_libraries("mono-component-${component}" PRIVATE monosgen-shared)
endif()
target_link_libraries("mono-component-${component}" PRIVATE ${OS_LIBS})
install(TARGETS "mono-component-${component}" LIBRARY)
install_with_stripped_symbols("mono-component-${component}" TARGETS lib)
endforeach()

#define a library for each component and component stub
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/eventpipe/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if(ENABLE_PERFTRACING)
if(ICU_LDFLAGS)
set_target_properties(ep-test PROPERTIES LINK_FLAGS ${ICU_LDFLAGS})
endif()
install(TARGETS ep-test RUNTIME)
install_with_stripped_symbols(ep-test TARGETS bin)
else(ENABLE_EVENTPIPE_TEST AND STATIC_COMPONENTS AND (NOT DISABLE_COMPONENTS) AND (NOT DISABLE_LIBS) AND (NOT DISABLE_EXECUTABLES))
message(VERBOSE "Skip building native EventPipe library test runner.")
endif(ENABLE_EVENTPIPE_TEST AND STATIC_COMPONENTS AND (NOT DISABLE_COMPONENTS) AND (NOT DISABLE_LIBS) AND (NOT DISABLE_EXECUTABLES))
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,3 @@ target_compile_definitions(metadata_objects PRIVATE -DMONO_DLL_EXPORT)
target_include_directories(metadata_objects PRIVATE ${PROJECT_BINARY_DIR}/../..
${PROJECT_SOURCE_DIR}/../..
${PROJECT_SOURCE_DIR}/..)

11 changes: 3 additions & 8 deletions src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ if(NOT DISABLE_SHARED_LIBS)
# if components are disabled, link the fallback stubs into the runtime
target_sources(monosgen-shared PRIVATE "${mono-components-stub-objects}")
endif()
install(TARGETS monosgen-shared LIBRARY)
install_with_stripped_symbols(monosgen-shared TARGETS lib)
if(HOST_WIN32 AND TARGET_AMD64)
add_library(monosgen-shared-dac SHARED "mini-windows-dlldac.c")
target_link_libraries(monosgen-shared-dac PRIVATE monoapi eglib_api)
Expand Down Expand Up @@ -452,9 +452,7 @@ if(NOT DISABLE_SHARED_LIBS)
FRAMEWORK_VERSION C
MACOSX_FRAMEWORK_IDENTIFIER net.dot.mono-framework
)
install(TARGETS ${frameworkconfig}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install_with_stripped_symbols(${frameworkconfig} TARGETS ${CMAKE_INSTALL_LIBDIR})
endforeach()
endif()
endif()
Expand Down Expand Up @@ -567,8 +565,5 @@ if(NOT DISABLE_EXECUTABLES)
target_sources(mono-sgen PRIVATE ${mono_validate_apis_source})
endif()

install(TARGETS mono-sgen RUNTIME)
if(HOST_WIN32)
install(FILES $<TARGET_PDB_FILE:mono-sgen> DESTINATION bin OPTIONAL)
endif()
install_with_stripped_symbols(mono-sgen TARGETS bin)
endif()