Skip to content

Commit 4595e44

Browse files
am11gwr
authored andcommitted
Misc. illumous build fixes
Co-authored-by: Adeel Mujahid <[email protected]> * Workaround gh-116929 Update eng/Subsets.props * Fix compile error at minipal/debugger.c:127 dotnet/runtime/src/native/minipal/debugger.c:127:5: error: implicit declaration of function 'snprintf' [-Werror=implicit-function-declaration] 127 | snprintf(statusFilename, sizeof(statusFilename), "/proc/%d/status", getpid()); | ^~~~~~~~ * Fix compile error in minipal/thread.h src/native/minipal/thread.h:73:23: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 73 | tid = (size_t)(void*)pthread_self(); | ^~~~~~~~~~~~~~~~~~~~~ * Fix compile error in native/libs/System.Native/pal_mount.c src/native/libs/System.Native/pal_mount.c:164:38: error: 'struct statvfs' has no member named 'f_type' 164 | *formatType = (int64_t)(stats.f_type); | ^ * Fix compile error in coreclr/pal/src/thread/thread.cpp /home/gwr/dotnet/runtime/src/coreclr/pal/src/thread/thread.cpp:1367:5: error: 'cid' was not declared in this scope 1367 | cid = CLOCK_THREAD_CPUTIME_ID; | ^~~ * Fix compile error in coreclr/vm/appdomain.hpp src/coreclr/vm/appdomain.hpp:1934:40: error: declaration of 'constexpr SystemDomain** const cdac_data<SystemDomain>::SystemDomain' changes meaning of 'SystemDomain' [-Wchanges-meaning] 1934 | static constexpr PTR_SystemDomain* SystemDomain = &SystemDomain::m_pSystemDomain; | ^~~~~~~~~~~~ src/coreclr/vm/appdomain.hpp:1934:56: note: used here to mean 'class SystemDomain' 1934 | static constexpr PTR_SystemDomain* SystemDomain = &SystemDomain::m_pSystemDomain; | ^~~~~~~~~~~~ src/coreclr/vm/appdomain.hpp:1629:7: note: declared here 1629 | class SystemDomain final | ^~~~~~~~~~~~ * Fix compile error in coreclr/runtime/amd64/AllocFast.S coreclr/runtime/amd64/AllocFast.S: Assembler messages: coreclr/runtime/amd64/AllocFast.S:237: Error: missing ')' * Add HAVE_DIRENT_D_TYPE introspection * Fix compile errors in coreclr/tools/superpmi/mcs/verbmerge.cpp /runtime/src/coreclr/tools/superpmi/mcs/verbmerge.cpp: In static member function 'static bool verbMerge::DirectoryFilterDirectories(FilterArgType*)': /runtime/src/coreclr/tools/superpmi/mcs/verbmerge.cpp:188:19: error: 'verbMerge::FilterArgType' {aka 'struct dirent'} has no member named 'd_type' 188 | if (findData->d_type == DT_DIR) | ^~~~~~ and similar a few other places in this file Let FilterArgType use struct FindData to simplify filters.
1 parent 6da0fa9 commit 4595e44

File tree

17 files changed

+102
-22
lines changed

17 files changed

+102
-22
lines changed

eng/Subsets.props

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
<_NativeAotSupportedArch Condition="'$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'loongarch64' or '$(TargetArchitecture)' == 'riscv64' or ('$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'x86')">true</_NativeAotSupportedArch>
5252
<NativeAotSupported Condition="'$(_NativeAotSupportedOS)' == 'true' and '$(_NativeAotSupportedArch)' == 'true'">true</NativeAotSupported>
5353

54+
<!-- TODO: workaround for https://github.com/dotnet/runtime/issues/116929 -->
55+
<_Crossgen2Supported Condition="'$(TargetOS)' != 'illumos' and '$(TargetOS)' != 'solaris'">true</_Crossgen2Supported>
56+
5457
<!-- Determine if we support running the .NET SDK on the target platform -->
5558
<_SdkToolsSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true</_SdkToolsSupportedOS>
5659
<_SdkToolsSupportedArch Condition="'$(TargetArchitecture)' != 'armel'">true</_SdkToolsSupportedArch>
@@ -440,7 +443,7 @@
440443
<ProjectToBuild Include="$(CoreClrProjectRoot).nuget\Microsoft.CrossOsDiag.Private.CoreCLR\Microsoft.CrossOsDiag.Private.CoreCLR.proj" Category="clr" />
441444
</ItemGroup>
442445

443-
<ItemGroup Condition="$(_subset.Contains('+clr.tools+'))">
446+
<ItemGroup Condition="$(_subset.Contains('+clr.tools+')) and '$(_Crossgen2Supported)' == 'true'">
444447
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\runincontext\runincontext.csproj;
445448
$(CoreClrProjectRoot)tools\tieringtest\tieringtest.csproj;
446449
$(CoreClrProjectRoot)tools\r2rdump\R2RDump.csproj;
@@ -676,7 +679,7 @@
676679
<SharedFrameworkProjectToBuild Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Ref.sfxproj" />
677680
</ItemGroup>
678681
<ItemGroup>
679-
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' != 'Mono' and ('$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true')" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Crossgen2.sfxproj" />
682+
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' != 'Mono' and ('$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true') and '$(_Crossgen2Supported)' == 'true'" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Crossgen2.sfxproj" />
680683
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)' and '$(TargetsMobile)' != 'true'" Include="$(InstallerProjectRoot)pkg\sfx\installers\dotnet-host.proj" />
681684
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)' and '$(TargetsMobile)' != 'true'" Include="$(InstallerProjectRoot)pkg\sfx\installers\dotnet-hostfxr.proj" />
682685
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)' and '$(TargetsMobile)' != 'true'" Include="$(InstallerProjectRoot)pkg\sfx\installers\dotnet-runtime-deps\*.proj" />
@@ -691,7 +694,7 @@
691694
When we're building in the VMR, we need to provide a crossgen2 that runs on the host machine for downstream repos to use to R2R their code.
692695
In non-VMR builds, downstream repos can use the crossgen2 built for the target host SDK from another build leg, but in the VMR we need to provide one to use.
693696
-->
694-
<ProjectToBuild Condition="'$(RuntimeFlavor)' != 'Mono' and '$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(BuildHostTools)' == 'true'" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Crossgen2.Host.sfxproj" Category="packs" />
697+
<ProjectToBuild Condition="'$(RuntimeFlavor)' != 'Mono' and '$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(BuildHostTools)' == 'true' and '$(_Crossgen2Supported)' == 'true'" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Crossgen2.Host.sfxproj" Category="packs" />
695698
</ItemGroup>
696699
<ItemGroup>
697700
<SharedFrameworkProjectToBuild Condition="'$(_BuildHostPack)' == 'true'" Include="$(InstallerProjectRoot)pkg\archives\dotnet-nethost.proj" />

eng/targetingpacks.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
LatestRuntimeFrameworkVersion="$(ProductVersion)"
4545
RuntimeFrameworkName="$(LocalFrameworkOverrideName)"
4646
RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.**RID**"
47-
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;linux-s390x;linux-bionic-arm;linux-bionic-arm64;linux-bionic-x64;linux-bionic-x86;freebsd-x64;freebsd-arm64;linux-ppc64le;linux-riscv64;linux-musl-riscv64;linux-loongarch64;linux-musl-loongarch64"
47+
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;linux-s390x;linux-bionic-arm;linux-bionic-arm64;linux-bionic-x64;linux-bionic-x86;freebsd-x64;freebsd-arm64;illumos-x64;solaris-x64;linux-ppc64le;linux-riscv64;linux-musl-riscv64;linux-loongarch64;linux-musl-loongarch64"
4848
TargetFramework="$(NetCoreAppCurrent)"
4949
TargetingPackName="$(LocalFrameworkOverrideName).Ref"
5050
TargetingPackVersion="$(ProductVersion)"

src/coreclr/debug/runtimeinfo/datadescriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ CDAC_GLOBAL_STRING(RID, RID_STRING)
868868
CDAC_GLOBAL(GCInfoVersion, uint32, GCINFO_VERSION)
869869

870870
CDAC_GLOBAL_POINTER(AppDomain, &AppDomain::m_pTheAppDomain)
871-
CDAC_GLOBAL_POINTER(SystemDomain, cdac_data<SystemDomain>::SystemDomain)
871+
CDAC_GLOBAL_POINTER(SystemDomain, cdac_data<SystemDomain>::SystemDomainPtr)
872872
CDAC_GLOBAL_POINTER(ThreadStore, &ThreadStore::s_pThreadStore)
873873
CDAC_GLOBAL_POINTER(FinalizerThread, &::g_pFinalizerThread)
874874
CDAC_GLOBAL_POINTER(GCThread, &::g_pSuspensionThread)

src/coreclr/pal/src/thread/thread.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,10 +1330,9 @@ CorUnix::GetThreadTimesInternal(
13301330
CPalThread *pThread;
13311331
CPalThread *pTargetThread;
13321332
IPalObject *pobjThread = NULL;
1333+
clockid_t cid;
13331334
#ifdef __sun
13341335
int fd;
1335-
#else // __sun
1336-
clockid_t cid;
13371336
#endif // __sun
13381337

13391338
pThread = InternalGetCurrentThread();

src/coreclr/runtime/amd64/AllocFast.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ LEAF_ENTRY RhpNewPtrArrayFast, _TEXT
234234

235235
// Delegate overflow handling to the generic helper conservatively
236236

237-
cmp rsi, (0x40000000 / 8) // sizeof(void*)
237+
cmp rsi, 0x8000000 // (0x40000000 / sizeof(void*))
238238
jae C_FUNC(RhpNewArrayFast)
239239

240240
// In this case we know the element size is sizeof(void *), or 8 for x64

src/coreclr/tools/superpmi/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
include(configure.cmake)
2+
include_directories(${CMAKE_CURRENT_BINARY_DIR})
3+
14
add_subdirectory(superpmi)
25
add_subdirectory(mcs)
36
add_subdirectory(superpmi-shim-collector)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
#ifndef __CONFIG_H__
5+
#define __CONFIG_H__
6+
7+
#cmakedefine01 HAVE_DIRENT_D_TYPE
8+
9+
#endif // __CONFIG_H__
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include(CheckStructHasMember)
2+
3+
check_struct_has_member ("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE)
4+
5+
configure_file(
6+
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
7+
${CMAKE_CURRENT_BINARY_DIR}/config.h)

src/coreclr/tools/superpmi/mcs/verbmerge.cpp

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
#include "simpletimer.h"
77
#include "logging.h"
88
#include "spmiutil.h"
9+
#include "config.h"
910
#include <stdio.h>
1011
#ifdef TARGET_UNIX
1112
#include <sys/types.h>
1213
#include <dirent.h>
1314
#include <fnmatch.h>
14-
#endif
15+
#ifndef DT_UNKNOWN
16+
#define DT_UNKNOWN 0
17+
#define DT_DIR 4
18+
#define DT_REG 8
19+
#define DT_LNK 10
20+
#endif // !DT_UNKNOWN
21+
#endif // TARGET_UNIX
1522

1623
#include <utility>
1724

@@ -187,9 +194,9 @@ bool verbMerge::DirectoryFilterDirectories(FilterArgType* findData)
187194
#else // TARGET_WINDOWS
188195
if (findData->d_type == DT_DIR)
189196
{
190-
if (strcmp(findData->d_name, ".") == 0)
197+
if (u16_strcmp(findData->cFileName, W(".")) == 0)
191198
return false;
192-
if (strcmp(findData->d_name, "..") == 0)
199+
if (u16_strcmp(findData->cFileName, W("..")) == 0)
193200
return false;
194201

195202
return true;
@@ -281,12 +288,47 @@ int verbMerge::FilterDirectory(LPCWSTR dir,
281288
dirent *pEntry = readdir(pDir);
282289
while (pEntry != nullptr)
283290
{
284-
if ((fnmatch(searchPatternUtf8.c_str(), pEntry->d_name, 0) == 0) && filter(pEntry))
291+
int dirEntryType;
292+
293+
#if HAVE_DIRENT_D_TYPE
294+
dirEntryType = pEntry->d_type;
295+
#else
296+
struct stat sb;
297+
298+
if (fstatat(dirfd(pDir), pEntry->d_name, &sb, 0) == -1)
299+
{
300+
continue;
301+
}
302+
303+
if (S_ISDIR(sb.st_mode)) {
304+
dirEntryType = DT_DIR;
305+
} else if (S_ISREG(sb.st_mode)) {
306+
dirEntryType = DT_REG;
307+
} else if (S_ISLNK(sb.st_mode)) {
308+
dirEntryType = DT_LNK;
309+
} else {
310+
dirEntryType = DT_UNKNOWN;
311+
}
312+
#endif
313+
if (dirEntryType == DT_UNKNOWN)
285314
{
286-
FindData findData(pEntry->d_type, ConvertMultiByteToWideChar(pEntry->d_name));
287-
first = new findDataList(&findData, first);
288-
++elemCount;
315+
continue;
289316
}
317+
318+
if (fnmatch(searchPatternUtf8.c_str(), pEntry->d_name, 0) != 0)
319+
{
320+
continue;
321+
}
322+
323+
FindData findData(dirEntryType, ConvertMultiByteToWideChar(pEntry->d_name));
324+
if (!filter(&findData))
325+
{
326+
continue;
327+
}
328+
329+
first = new findDataList(&findData, first);
330+
++elemCount;
331+
290332
errno = 0;
291333
pEntry = readdir(pDir);
292334
}

src/coreclr/tools/superpmi/mcs/verbmerge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class verbMerge
6565
#ifdef TARGET_WINDOWS
6666
typedef _WIN32_FIND_DATAW FilterArgType;
6767
#else
68-
typedef struct dirent FilterArgType;
68+
typedef struct FindData FilterArgType;
6969
#endif
7070

7171
typedef bool (*DirectoryFilterFunction_t)(FilterArgType*);

src/coreclr/vm/appdomain.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,7 @@ inline static BOOL IsUnderDomainLock() { LIMITED_METHOD_CONTRACT; return m_Syste
19311931
template<>
19321932
struct cdac_data<SystemDomain>
19331933
{
1934-
static constexpr PTR_SystemDomain* SystemDomain = &SystemDomain::m_pSystemDomain;
1934+
static constexpr PTR_SystemDomain* SystemDomainPtr = &SystemDomain::m_pSystemDomain;
19351935
};
19361936
#endif // DACCESS_COMPILE
19371937

src/installer/pkg/projects/netcoreappRIDs.props

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
<OfficialBuildRID Include="osx-arm64">
1010
<Platform>arm64</Platform>
1111
</OfficialBuildRID>
12-
<!-- Not currently built by CoreFX. -->
13-
<!-- <OfficialBuildRID Include="netbsd-x64" /> -->
14-
<!-- <OfficialBuildRID Include="illumos-x64" /> -->
15-
<!-- <OfficialBuildRID Include="solaris-x64" /> -->
16-
<!-- <OfficialBuildRID Include="haiku-x64" /> -->
1712
<OfficialBuildRID Include="win-x86">
1813
<Platform>x86</Platform>
1914
</OfficialBuildRID>
@@ -51,6 +46,10 @@
5146
in our runtime.json to enable others to provide them. -->
5247
<UnofficialBuildRID Include="freebsd-x64" />
5348
<UnofficialBuildRID Include="freebsd-arm64" />
49+
<UnofficialBuildRID Include="illumos-x64" />
50+
<UnofficialBuildRID Include="solaris-x64" />
51+
<UnofficialBuildRID Include="netbsd-x64" />
52+
<UnofficialBuildRID Include="haiku-x64" />
5453
<UnofficialBuildRID Include="tizen.4.0.0-armel">
5554
<Platform>armel</Platform>
5655
</UnofficialBuildRID>

src/native/libs/Common/pal_config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#cmakedefine01 HAVE_MNTINFO
3232
#cmakedefine01 HAVE_STATFS_FSTYPENAME
3333
#cmakedefine01 HAVE_STATVFS_FSTYPENAME
34+
#cmakedefine01 HAVE_STATVFS_BASETYPE
3435
#cmakedefine01 HAVE_NON_LEGACY_STATFS
3536
#cmakedefine01 HAVE_STRCPY_S
3637
#cmakedefine01 HAVE_STRLCPY

src/native/libs/System.Native/pal_mount.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ SystemNative_GetFileSystemTypeNameForMountPoint(const char* name, char* formatNa
159159
}
160160
SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), stats.f_fstypename);
161161
*formatType = -1;
162+
#elif HAVE_STATVFS_BASETYPE
163+
if (bufferLength < _FSTYPSZ) // SunOS
164+
{
165+
errno = ERANGE;
166+
result = -1;
167+
}
168+
SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), stats.f_basetype);
169+
*formatType = -1;
162170
#else
163171
SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), "");
164172
*formatType = (int64_t)(stats.f_type);

src/native/libs/configure.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ check_struct_has_member(
324324
"sys/mount.h"
325325
HAVE_STATVFS_FSTYPENAME)
326326

327+
check_struct_has_member(
328+
"struct statvfs"
329+
f_basetype
330+
"sys/statvfs.h"
331+
HAVE_STATVFS_BASETYPE)
332+
327333
set(CMAKE_EXTRA_INCLUDE_FILES dirent.h)
328334

329335
# statfs: Find whether this struct exists

src/native/minipal/debugger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <sys/proc.h>
3333
#define MINIPAL_DEBUGGER_PRESENT_CHECK
3434
#elif defined(__sun)
35+
#include <stdio.h>
3536
#include <fcntl.h>
3637
#include <procfs.h>
3738
#include <errno.h>

src/native/minipal/thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ static inline size_t minipal_get_current_thread_id(void)
6969
tid = (size_t)_lwp_self();
7070
#elif defined(__HAIKU__)
7171
tid = (size_t)find_thread(NULL);
72+
#elif defined(__sun)
73+
tid = (size_t)pthread_self();
7274
#else
7375
tid = (size_t)(void*)pthread_self();
7476
#endif

0 commit comments

Comments
 (0)