Skip to content

Commit 60c85dc

Browse files
committed
支持鸿蒙,以及鸿蒙的编译脚本
1 parent 80aa709 commit 60c85dc

File tree

7 files changed

+39
-5
lines changed

7 files changed

+39
-5
lines changed

build-openharmony-arm64.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
sudo docker run --rm \
3+
-v ./:/runtime \
4+
-w /runtime \
5+
-e ROOTFS_DIR="/crossrootfs/arm64" \
6+
mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm64-musl \
7+
bash -c "./build.sh --subset clr.aot+libs --configuration Release -arch arm64 --cross \
8+
&& mkdir -p ./artifacts/openharmony/arm64/sdk/ \
9+
&& 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/"

build-openharmony-x64.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
sudo docker run --rm \
3+
-v ./:/runtime \
4+
-w /runtime \
5+
-e ROOTFS_DIR="/crossrootfs/x64" \
6+
mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64-musl \
7+
bash -c "./build.sh --subset clr.aot+libs --configuration Release -arch x64 --cross \
8+
&& mkdir -p ./artifacts/openharmony/x64/sdk/ \
9+
&& 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/"

eng/native/configurecompiler.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,8 @@ 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>)
725727
endif()
726728
elseif(CLR_CMAKE_TARGET_NETBSD)
727729
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_NETBSD>)

src/coreclr/gc/gcpriv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ inline void FATAL_GC_ERROR()
144144
// For SunOS or illumos this is temporary, until we can add MAP_PRIVATE
145145
// to the mmap() calls in unix/gcenv.unix.cpp More details here:
146146
// https://github.com/dotnet/runtime/issues/104211
147-
#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__) && !defined(__sun)
147+
#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__) && !defined(__sun) && !defined(TARGET_OPENHARMONY)
148148
#define USE_REGIONS
149149
#endif //HOST_64BIT && BUILD_AS_STANDALONE && !__APPLE__
150150

src/coreclr/gc/unix/numasupport.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int g_highestNumaNode = 0;
1818
// Is numa available
1919
bool g_numaAvailable = false;
2020

21-
#ifdef TARGET_LINUX
21+
#if defined(TARGET_LINUX) && !defined(TARGET_OPENHARMONY)
2222
static int GetNodeNum(const char* path, bool firstOnly)
2323
{
2424
DIR *dir;
@@ -53,7 +53,8 @@ static int GetNodeNum(const char* path, bool firstOnly)
5353

5454
void NUMASupportInitialize()
5555
{
56-
#ifdef TARGET_LINUX
56+
#if defined(TARGET_LINUX) && !defined(TARGET_OPENHARMONY)
57+
111
5758
if (syscall(__NR_get_mempolicy, NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS)
5859
return;
5960

@@ -69,7 +70,7 @@ void NUMASupportInitialize()
6970

7071
int GetNumaNodeNumByCpu(int cpu)
7172
{
72-
#ifdef TARGET_LINUX
73+
#if defined(TARGET_LINUX) && !defined(TARGET_OPENHARMONY)
7374
char path[64];
7475
if (snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d", cpu) < 0)
7576
return -1;
@@ -82,7 +83,7 @@ int GetNumaNodeNumByCpu(int cpu)
8283

8384
long BindMemoryPolicy(void* start, unsigned long len, const unsigned long* nodemask, unsigned long maxnode)
8485
{
85-
#ifdef TARGET_LINUX
86+
#if defined(TARGET_LINUX) && !defined(TARGET_OPENHARMONY)
8687
return syscall(__NR_mbind, (long)start, len, 1, (long)nodemask, maxnode, 0);
8788
#else
8889
return -1;

src/coreclr/gc/vxsort/isa_detection.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ SupportedISA DetermineSupportedISA()
8484

8585
SupportedISA DetermineSupportedISA()
8686
{
87+
#ifdef TARGET_OPENHARMONY
88+
return SupportedISA::None;
89+
#else
8790
__builtin_cpu_init();
8891
if (__builtin_cpu_supports("avx2"))
8992
{
@@ -96,6 +99,7 @@ SupportedISA DetermineSupportedISA()
9699
{
97100
return SupportedISA::None;
98101
}
102+
#endif
99103
}
100104

101105
#endif // defined(TARGET_UNIX)

src/native/libs/System.Globalization.Native/pal_icushim.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ int32_t GlobalizationNative_LoadICU(void)
505505

506506
#if defined(ANDROID_FORCE_ICU_DATA_DIR)
507507
setenv ("ICU_DATA", "/system/usr/icu/", 0);
508+
#endif
509+
#ifdef TARGET_OPENHARMONY
510+
setenv ("ICU_DATA", "/system/usr/ohos_icu", 0);
508511
#endif
509512
FOR_ALL_ICU_FUNCTIONS
510513
ValidateICUDataCanLoad();

0 commit comments

Comments
 (0)