Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[arccon] Add optional dotnet wrapper to prevent first time use race condition #1791

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 21 additions & 2 deletions arccon/build-system/ArcconDotNet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,34 @@ set(ARCCON_MSBUILD_COMMON_ARGS /nodeReuse:false ${ARCCON_MSBUILD_RESTORE_ARGS})
find_program(DOTNET_EXEC NAMES dotnet)
message(STATUS "[.Net] DOTNET exe: ${DOTNET_EXEC}")
if (DOTNET_EXEC)
# Avec '.Net' (au moins pour les versions 6 à 8), il y a un conflit
# potentiel de lock sur les fichiers lors d'une premier appel de 'dotnet'
# si plusieurs instances sont lancées à la fois
# (voir par exemple https://github.com/dotnet/runtime/issues/91987 ou
# https://github.com/dotnet/runtime/issues/80619)
# Pour éviter cela, on créé un wrapper à 'dotnet' qui utilise un HOME local
# au projet et on utiliser ce wrapper
if (UNIX AND NOT ARCCON_NO_WRAPPER_FOR_DOTNET)
set(ARCCON_DOTNET_FAKEHOME "${CMAKE_CURRENT_BINARY_DIR}/fakehome")
set(ARCCON_DOTNET_WRAPPER "${ARCCON_DOTNET_FAKEHOME}/arccon_dotnet")
cmake_path(GET DOTNET_EXEC PARENT_PATH ARCCON_DOTNET_PATH)
file(MAKE_DIRECTORY ${ARCCON_DOTNET_FAKEHOME})
configure_file(${CMAKE_CURRENT_LIST_DIR}/arccon_dotnet.in ${ARCCON_DOTNET_WRAPPER} USE_SOURCE_PERMISSIONS @ONLY)
message(STATUS "Using wrapper '${ARCCON_DOTNET_WRAPPER}' for '${DOTNET_EXEC}'")
set(DOTNET_EXEC_WRAPPER "${ARCCON_DOTNET_WRAPPER}")
else()
set(DOTNET_EXEC_WRAPPER "${DOTNET_EXEC}")
endif()

set(ARCCON_DOTNET_HAS_RUNTIME_coreclr TRUE)
set(ARCCON_MSBUILD_EXEC_coreclr ${DOTNET_EXEC})
set(ARCCON_MSBUILD_EXEC_coreclr ${DOTNET_EXEC_WRAPPER})
# Pour les options, voir le CMakeLists.txt de 'axlstar'
set(ARCCON_MSBUILD_ARGS_coreclr publish /p:UseSharedCompilation=false ${ARCCON_MSBUILD_COMMON_ARGS})
# Arguments pour fabriquer les packages NuGet
set(ARCCON_DOTNET_PACK_ARGS_coreclr pack --no-build --no-restore --no-dependencies /nodeReuse:false)

# Récupère le numéro de version 'dotnet'
execute_process(COMMAND ${DOTNET_EXEC} "--version" OUTPUT_VARIABLE CORECLR_EXEC_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${DOTNET_EXEC_WRAPPER} "--version" OUTPUT_VARIABLE CORECLR_EXEC_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.(.*)" CORECLR_VERSION_REGEX_MATCH ${CORECLR_EXEC_VERSION_OUTPUT})
set(CORECLR_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2})
set(CORECLR_VERSION_FULL ${CORECLR_VERSION}.${CMAKE_MATCH_3})
Expand Down
6 changes: 6 additions & 0 deletions arccon/build-system/arccon_dotnet.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
export HOME=@ARCCON_DOTNET_FAKEHOME@
# To disable telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1

@ARCCON_DOTNET_PATH@/dotnet "$@"
Loading