Skip to content

Commit 435caa7

Browse files
committed
增加编译参数 --os openharmony
1 parent dc4d2cb commit 435caa7

File tree

16 files changed

+105
-36
lines changed

16 files changed

+105
-36
lines changed

Directory.Build.props

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@
211211
<!-- Detect linux flavors using __PortableTargetOS from the native script. -->
212212
<_portableOS Condition="'$(_portableOS)' == 'linux' and '$(__PortableTargetOS)' == 'linux-musl'">linux-musl</_portableOS>
213213
<_portableOS Condition="'$(_portableOS)' == 'linux' and '$(__PortableTargetOS)' == 'linux-bionic'">linux-bionic</_portableOS>
214+
215+
<_portableOS Condition="'$(_portableOS)' == 'openharmony'">linux-musl</_portableOS>
214216

215217
<!-- On Windows, we can build for Windows and Mobile.
216218
For other TargetOSes, create a "win" build, built from TargetOS sources and "win" pre-built packages. -->
@@ -272,7 +274,7 @@
272274
<Targetsillumos Condition="'$(TargetOS)' == 'illumos'">true</Targetsillumos>
273275
<TargetsSolaris Condition="'$(TargetOS)' == 'solaris'">true</TargetsSolaris>
274276
<TargetsHaiku Condition="'$(TargetOS)' == 'haiku'">true</TargetsHaiku>
275-
<TargetsLinux Condition="'$(TargetOS)' == 'linux' or '$(TargetOS)' == 'android'">true</TargetsLinux>
277+
<TargetsLinux Condition="'$(TargetOS)' == 'linux' or '$(TargetOS)' == 'android' or '$(TargetOS)' == 'openharmony'">true</TargetsLinux>
276278
<TargetsLinuxBionic Condition="'$(_portableOS)' == 'linux-bionic'">true</TargetsLinuxBionic>
277279
<TargetsLinuxMusl Condition="'$(_portableOS)' == 'linux-musl'">true</TargetsLinuxMusl>
278280
<TargetsNetBSD Condition="'$(TargetOS)' == 'netbsd'">true</TargetsNetBSD>
@@ -283,10 +285,11 @@
283285
<TargetsiOSSimulator Condition="'$(TargetOS)' == 'iossimulator'">true</TargetsiOSSimulator>
284286
<TargetstvOSSimulator Condition="'$(TargetOS)' == 'tvossimulator'">true</TargetstvOSSimulator>
285287
<TargetsAndroid Condition="'$(TargetOS)' == 'android'">true</TargetsAndroid>
288+
<TargetsOpenHarmony Condition="'$(TargetOS)' == 'openharmony'">true</TargetsOpenHarmony>
286289
<TargetsBrowser Condition="'$(TargetOS)' == 'browser'">true</TargetsBrowser>
287290
<TargetsWasi Condition="'$(TargetOS)' == 'wasi'">true</TargetsWasi>
288291
<TargetsWindows Condition="'$(TargetOS)' == 'windows'">true</TargetsWindows>
289-
<TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(Targetsillumos)' == 'true' or '$(TargetsSolaris)' == 'true' or '$(TargetsHaiku)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true'">true</TargetsUnix>
292+
<TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(Targetsillumos)' == 'true' or '$(TargetsSolaris)' == 'true' or '$(TargetsHaiku)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsOpenHarmony)' == 'true'">true</TargetsUnix>
290293
</PropertyGroup>
291294

292295
<PropertyGroup>

build-openharmony-arm.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

build-openharmony-arm64.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ docker run --rm \
44
-w /runtime \
55
-e ROOTFS_DIR="/crossrootfs/arm64" \
66
mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net9.0-cross-arm64-musl \
7-
bash -c "./build.sh --subset clr.aot+libs --configuration Release -arch arm64 --cross \
7+
bash -c "./build.sh --subset clr.aot+libs --configuration Release -arch arm64 --cross --os openharmony\
88
&& mkdir -p ./artifacts/openharmony/arm64/sdk/ \
99
&& mkdir -p ./artifacts/openharmony/arm64/framework/ \
10-
&& cp -p ./artifacts/bin/coreclr/linux.arm64.Release/aotsdk/* ./artifacts/openharmony/arm64/sdk/ \
11-
&& cp -p ./artifacts/bin/runtime/net9.0-linux-Release-arm64/*.a ./artifacts/openharmony/arm64/framework/ \
12-
&& cp -p ./artifacts/bin/runtime/net9.0-linux-Release-arm64/*.dbg ./artifacts/openharmony/arm64/framework/"
10+
&& cp -p ./artifacts/bin/coreclr/openharmony.arm64.Release/aotsdk/* ./artifacts/openharmony/arm64/sdk/ \
11+
&& cp -p ./artifacts/bin/runtime/net9.0-openharmony-Release-arm64/*.a ./artifacts/openharmony/arm64/framework/ \
12+
&& cp -p ./artifacts/bin/runtime/net9.0-openharmony-Release-arm64/*.dbg ./artifacts/openharmony/arm64/framework/"

build-openharmony-x64.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ docker run --rm \
44
-w /runtime \
55
-e ROOTFS_DIR="/crossrootfs/x64" \
66
mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net9.0-cross-amd64-musl \
7-
bash -c "./build.sh --subset clr.aot+libs --configuration Release -arch x64 --cross \
7+
bash -c "./build.sh --subset clr.aot+libs --configuration Release -arch x64 --cross --os openharmony\
88
&& mkdir -p ./artifacts/openharmony/x64/sdk/ \
99
&& mkdir -p ./artifacts/openharmony/x64/framework/ \
10-
&& cp -p ./artifacts/bin/coreclr/linux.x64.Release/aotsdk/* ./artifacts/openharmony/x64/sdk/ \
11-
&& cp -p ./artifacts/bin/runtime/net9.0-linux-Release-x64/*.a ./artifacts/openharmony/x64/framework/ \
12-
&& cp -p ./artifacts/bin/runtime/net9.0-linux-Release-x64/*.dbg ./artifacts/openharmony/x64/framework/"
10+
&& cp -p ./artifacts/bin/coreclr/openharmony.x64.Release/aotsdk/* ./artifacts/openharmony/x64/sdk/ \
11+
&& cp -p ./artifacts/bin/runtime/net9.0-openharmony-Release-x64/*.a ./artifacts/openharmony/x64/framework/ \
12+
&& cp -p ./artifacts/bin/runtime/net9.0-openharmony-Release-x64/*.dbg ./artifacts/openharmony/x64/framework/"

eng/Subsets.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119

120120
<PropertyGroup>
121121
<!-- CLR NativeAot only builds in a subset of the matrix -->
122-
<_NativeAotSupportedOS Condition="'$(TargetOS)' == 'windows' or '$(TargetOS)' == 'linux' or '$(TargetOS)' == 'osx' or '$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'freebsd'">true</_NativeAotSupportedOS>
122+
<_NativeAotSupportedOS Condition="'$(TargetOS)' == 'windows' or '$(TargetOS)' == 'linux' or '$(TargetOS)' == 'osx' or '$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'freebsd' or '$(TargetOS)' == 'openharmony'">true</_NativeAotSupportedOS>
123123
<_NativeAotSupportedArch Condition="'$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'loongarch64' or ('$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'x86')">true</_NativeAotSupportedArch>
124124
<NativeAotSupported Condition="'$(_NativeAotSupportedOS)' == 'true' and '$(_NativeAotSupportedArch)' == 'true'">true</NativeAotSupported>
125125
<UseNativeAotForComponents Condition="'$(NativeAotSupported)' == 'true' and '$(TargetOS)' == '$(HostOS)' and '$(TargetsLinuxBionic)' != 'true' and ('$(TargetsLinuxMusl)' != 'true' or '$(TargetArchitecture)' != 'arm')">true</UseNativeAotForComponents>

eng/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ while [[ $# > 0 ]]; do
298298
;;
299299
haiku)
300300
os="haiku" ;;
301+
openharmony)
302+
os="openharmony"
303+
__PortableTargetOS=linux-musl
304+
;;
301305
*)
302306
echo "Unsupported target OS '$2'."
303307
echo "Try 'build.sh --help' for values supported by '--os'."

eng/native/configurecompiler.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,9 @@ if(CLR_CMAKE_TARGET_UNIX)
722722
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_LINUX>)
723723
if(CLR_CMAKE_TARGET_LINUX_MUSL)
724724
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_LINUX_MUSL>)
725-
# 为OpenHarmony平台做的临时修改
726-
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_OPENHARMONY>)
725+
endif()
726+
if (CLR_CMAKE_TARGET_OPENHARMONY)
727+
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_OPENHARMONY>)
727728
endif()
728729
elseif(CLR_CMAKE_TARGET_NETBSD)
729730
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_NETBSD>)

eng/native/configureplatform.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ set(PRERELEASE 0)
99
# - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
1010
# - for windows we use the passed in parameter to CMAKE to determine build arch
1111
#----------------------------------------
12+
13+
message("CLR_CMAKE_TARGET_OS${CLR_CMAKE_TARGET_OS}")
14+
1215
set(CLR_CMAKE_HOST_OS ${CMAKE_SYSTEM_NAME})
1316
string(TOLOWER ${CLR_CMAKE_HOST_OS} CLR_CMAKE_HOST_OS)
1417
if(CLR_CMAKE_HOST_OS STREQUAL linux)
@@ -230,6 +233,13 @@ if(CLR_CMAKE_TARGET_OS STREQUAL wasi)
230233
set(CLR_CMAKE_HOST_WASI 1)
231234
endif(CLR_CMAKE_TARGET_OS STREQUAL wasi)
232235

236+
if(CLR_CMAKE_TARGET_OS STREQUAL openharmony)
237+
set(CLR_CMAKE_TARGET_UNIX 1)
238+
set(CLR_CMAKE_TARGET_LINUX 1)
239+
set(CLR_CMAKE_TARGET_LINUX_MUSL 1)
240+
set(CLR_CMAKE_TARGET_OPENHARMONY 1)
241+
endif(CLR_CMAKE_TARGET_OS STREQUAL openharmony)
242+
233243
#--------------------------------------------
234244
# This repo builds two set of binaries
235245
# 1. binaries which execute on target arch machine
@@ -471,7 +481,7 @@ if(CLR_CMAKE_TARGET_OS STREQUAL windows)
471481
endif()
472482

473483
# check if host & target os/arch combination are valid
474-
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI)
484+
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_OPENHARMONY)
475485
if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
476486
message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
477487
endif()

eng/native/gen-buildsys.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ if [[ "$host_arch" == "wasm" ]]; then
106106
fi
107107
fi
108108

109+
if [[ "$target_os" == "openharmony" ]]; then
110+
echo "openharmony"
111+
cmake_extra_defines="$cmake_extra_defines -DCLR_CMAKE_TARGET_OS=openharmony"
112+
fi
113+
114+
DCMAKE_TOOLCHAIN_FILE
109115
$cmake_command \
110116
--no-warn-unused-cli \
111117
-G "$generator" \

src/coreclr/gc/unix/numasupport.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static int GetNodeNum(const char* path, bool firstOnly)
5454
void NUMASupportInitialize()
5555
{
5656
#if defined(TARGET_LINUX) && !defined(TARGET_OPENHARMONY)
57-
111
5857
if (syscall(__NR_get_mempolicy, NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS)
5958
return;
6059

0 commit comments

Comments
 (0)