Skip to content

Commit

Permalink
[mono] Align HOST_TVOS/TARGET_TVOS defines with the rest of the repo (#…
Browse files Browse the repository at this point in the history
…89085)

In the mono build we've been setting HOST_IOS/TARGET_IOS when targeting tvOS which differs from the other runtime repo build systems and caused confusion. This aligns the defines so we only set the iOS ones on iOS and not on tvOS.

Also removes mono_dl_get_system_dir() since it was not actually used.
  • Loading branch information
akoeplinger committed Jul 18, 2023
1 parent 3dcf48e commit b8653d9
Show file tree
Hide file tree
Showing 22 changed files with 47 additions and 77 deletions.
18 changes: 10 additions & 8 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "ios" OR CLR_CMAKE_HOST_OS STREQUAL "tvos")
# control cross-compiling to ios
add_definitions(-D_THREAD_SAFE)
set(HOST_DARWIN 1)
set(HOST_IOS 1)
if(CLR_CMAKE_HOST_OS STREQUAL "tvos")
if(CLR_CMAKE_HOST_OS STREQUAL "ios")
set(HOST_IOS 1)
elseif(CLR_CMAKE_HOST_OS STREQUAL "tvos")
set(HOST_TVOS 1)
endif()
set(PTHREAD_POINTER_ID 1)
Expand Down Expand Up @@ -318,12 +319,13 @@ if(TARGET_SYSTEM_NAME STREQUAL "darwin")
elseif(TARGET_SYSTEM_NAME STREQUAL "ios" OR TARGET_SYSTEM_NAME STREQUAL "tvos")
set(TARGET_UNIX 1)
set(TARGET_MACH 1)
set(TARGET_IOS 1)
set(TARGET_DARWIN 1)
if(TARGET_SYSTEM_NAME STREQUAL "tvos")
set(TARGET_APPLE_MOBILE 1)
if(TARGET_SYSTEM_NAME STREQUAL "ios")
set(TARGET_IOS 1)
elseif(TARGET_SYSTEM_NAME STREQUAL "tvos")
set(TARGET_TVOS 1)
endif()
set(TARGET_APPLE_MOBILE 1)
elseif(TARGET_SYSTEM_NAME STREQUAL "linux")
set(TARGET_UNIX 1)
set(TARGET_LINUX 1)
Expand Down Expand Up @@ -729,7 +731,7 @@ elseif(HOST_BROWSER)
set(HAVE_SYS_ICU 1)
set(STATIC_ICU 1)
set(ICU_LIBS "icucore")
elseif(HOST_IOS OR HOST_MACCAT)
elseif(HOST_IOS OR HOST_TVOS OR HOST_MACCAT)
set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations")
set(HAVE_SYS_ICU 1)
set(STATIC_ICU 1)
Expand Down Expand Up @@ -934,7 +936,7 @@ set(FULL_VERSION ${product_version_string})
######################################
# OS SPECIFIC CHECKS
######################################
if(HOST_IOS OR HOST_ANDROID OR HOST_MACCAT)
if(HOST_IOS OR HOST_TVOS OR HOST_ANDROID OR HOST_MACCAT)
# FIXME: the mobile products use mono_dllmap_insert so allow this
unset(DISABLE_DLLMAP)
else()
Expand All @@ -958,7 +960,7 @@ endif()
add_subdirectory("${CLR_SRC_NATIVE_DIR}/public" public_apis)

add_subdirectory(mono)
if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT TARGET_WASI AND NOT HOST_MACCAT)
if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_TVOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT TARGET_WASI AND NOT HOST_MACCAT)
add_subdirectory(dlls/mscordbi)
endif()

Expand Down
4 changes: 2 additions & 2 deletions src/mono/cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ endif()

check_include_files("sys/types.h;sys/user.h" HAVE_SYS_USER_H)

if(HOST_IOS OR HOST_MACCAT)
if(HOST_IOS OR HOST_TVOS OR HOST_MACCAT)
# getentropy isn't allowed in the AppStore: https://github.com/rust-lang/rust/issues/102643
set(HAVE_GETENTROPY 0)
endif()
Expand Down Expand Up @@ -247,7 +247,7 @@ if(HOST_WIN32)
set(HAVE_STRUCT_SOCKADDR_IN6 1)
set(HAVE_STRTOK_R 1)
set(HAVE_EXECVP 0)
elseif(HOST_IOS)
elseif(HOST_IOS OR HOST_TVOS)
set(HAVE_SYSTEM 0)
set(HAVE_SYS_USER_H 0)
if(HOST_TVOS)
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@
#endif

/*
* On iOS we can't use System.Environment.Exit () as it will do the wrong
* On iOS/tvOS we can't use System.Environment.Exit () as it will do the wrong
* shutdown sequence.
*/
#if !defined (TARGET_IOS)
#if !defined (TARGET_IOS) && !defined(TARGET_TVOS)
#define TRY_MANAGED_SYSTEM_ENVIRONMENT_EXIT
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ mono_invoke_unhandled_exception_hook (MonoObject *exc)
}
mono_runtime_printf_err ("[ERROR] FATAL UNHANDLED EXCEPTION: %s", msg);
g_free (msg);
#if defined(HOST_IOS)
#if defined(HOST_IOS) || defined(HOST_TVOS)
g_assertion_message ("Terminating runtime due to unhandled exception");
#else
exit (mono_environment_exitcode_get ());
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(HOST_DARWIN)
if(CMAKE_SYSTEM_VARIANT STREQUAL "maccatalyst")
set(OS_LIBS ${OS_LIBS} "-lobjc" "-lc++")
endif()
elseif(HOST_IOS)
elseif(HOST_IOS OR HOST_TVOS)
set(OS_LIBS "-framework CoreFoundation" "-lobjc" "-lc++")
elseif(HOST_ANDROID)
set(OS_LIBS m dl log)
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/dwarfwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static int subprogram_attr [] = {
DW_AT_MIPS_linkage_name, DW_FORM_string,
DW_AT_decl_file , DW_FORM_udata,
DW_AT_decl_line , DW_FORM_udata,
#ifndef TARGET_IOS
#if !defined (TARGET_IOS) && !defined(TARGET_TVOS)
DW_AT_description , DW_FORM_string,
#endif
DW_AT_low_pc , DW_FORM_addr,
Expand Down Expand Up @@ -1828,7 +1828,7 @@ mono_dwarf_writer_emit_method (MonoDwarfWriter *w, MonoCompile *cfg, MonoMethod
emit_uleb128 (w, 0);
emit_uleb128 (w, 0);
}
#ifndef TARGET_IOS
#if !defined (TARGET_IOS) && !defined(TARGET_TVOS)
emit_string (w, name);
#endif
g_free (name);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/exceptions-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ mono_arch_unwind_frame (MonoJitTlsData *jit_tls,

for (i = 0; i < 16; ++i)
regs [i] = new_ctx->regs [i];
#ifdef TARGET_IOS
#if defined (TARGET_IOS) || defined(TARGET_TVOS)
/* On IOS, d8..d15 are callee saved. They are mapped to 8..15 in unwind.c */
for (i = 0; i < 8; ++i)
regs [MONO_MAX_IREGS + i] = *(guint64*)&(new_ctx->fregs [8 + i]);
Expand All @@ -509,7 +509,7 @@ mono_arch_unwind_frame (MonoJitTlsData *jit_tls,
new_ctx->regs [i] = regs [i];
new_ctx->pc = regs [ARMREG_LR];
new_ctx->regs [ARMREG_SP] = (gsize)cfa;
#ifdef TARGET_IOS
#if defined (TARGET_IOS) || defined(TARGET_TVOS)
for (i = 0; i < 8; ++i)
new_ctx->fregs [8 + i] = *(double*)&(regs [MONO_MAX_IREGS + i]);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/mini-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ mono_arch_init (void)
#else
arm_fpu = MONO_ARM_FPU_VFP;

#if defined(ARM_FPU_NONE) && !defined(TARGET_IOS)
#if defined(ARM_FPU_NONE) && !defined(TARGET_IOS) && !defined(TARGET_TVOS)
/*
* If we're compiling with a soft float fallback and it
* turns out that no VFP unit is available, we need to
Expand Down Expand Up @@ -870,7 +870,7 @@ mono_arch_init (void)
v7_supported = TRUE;
#endif

#if defined(TARGET_IOS)
#if defined(TARGET_IOS) || defined(TARGET_TVOS)
/* iOS is special-cased here because we don't yet
have a way to properly detect CPU features on it. */
thumb_supported = TRUE;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/mini-arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ mono_arch_cpu_init (void)
void
mono_arch_init (void)
{
#if defined(TARGET_IOS) || defined(TARGET_WATCHOS) || defined(TARGET_OSX)
#if defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(TARGET_WATCHOS) || defined(TARGET_OSX)
ios_abi = TRUE;
#endif
#ifdef MONO_ARCH_ENABLE_PTRAUTH
Expand Down Expand Up @@ -1097,7 +1097,7 @@ mono_arm_emit_aotconst (gpointer ji, guint8 *code, guint8 *code_start, int dreg,
gboolean
mono_arch_have_fast_tls (void)
{
#ifdef TARGET_IOS
#if defined(TARGET_IOS) || defined(TARGET_TVOS)
return FALSE;
#else
return TRUE;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/mini-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ typedef struct {
// can pass context to generics or interfaces?
#define MONO_ARCH_HAVE_VOLATILE_NON_PARAM_REGISTER 1

#ifdef TARGET_IOS
#if defined(TARGET_IOS) || defined(TARGET_TVOS)

#define MONO_ARCH_REDZONE_SIZE 128

Expand All @@ -196,7 +196,7 @@ typedef struct {

#endif

#if defined(TARGET_IOS) || defined(TARGET_WATCHOS)
#if defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(TARGET_WATCHOS)
#define MONO_ARCH_HAVE_UNWIND_BACKTRACE 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5114,7 +5114,7 @@ register_icalls (void)
register_icall_no_wrapper (mono_monitor_enter_fast, mono_icall_sig_int_obj);
register_icall_no_wrapper (mono_monitor_enter_v4_fast, mono_icall_sig_int_obj_ptr);

#ifdef TARGET_IOS
#if defined(TARGET_IOS) || defined(TARGET_TVOS)
register_icall (pthread_getspecific, mono_icall_sig_ptr_ptr, TRUE);
#endif
/* Register tls icalls */
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#pragma warning(disable:4312) // FIXME pointer cast to different size
#endif

#if defined (HOST_ANDROID) || defined (TARGET_IOS)
#if defined (HOST_ANDROID) || defined (TARGET_IOS) || defined(TARGET_TVOS)
# undef printf
# define printf(...) g_log("mono", G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
# undef fprintf
Expand Down
29 changes: 14 additions & 15 deletions src/mono/mono/tools/offsets-tool/offsets-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def get_clang_args(self):
if self.arch_define:
ret.append (self.arch_define)
if self.platform_define:
ret.append (self.platform_define)
if isinstance(self.platform_define, list):
ret.extend (self.platform_define)
else:
ret.append (self.platform_define)
if self.defines:
ret.extend (self.defines)
return ret
Expand Down Expand Up @@ -138,22 +141,12 @@ def require_emscipten_path (args):
self.target_args += ["-I", prefix + "/include"]
self.target_args += ["-I", prefix + "/include-fixed"]

# iOS
elif "arm-apple-darwin10" == args.abi:
require_sysroot (args)
self.target = Target ("TARGET_ARM", "TARGET_IOS", ["ARM_FPU_VFP", "HAVE_ARMV5"] + IOS_DEFINES)
self.target_args += ["-arch", "arm"]
self.target_args += ["-isysroot", args.sysroot]
# iOS/tvOS
elif "aarch64-apple-darwin10" == args.abi:
require_sysroot (args)
self.target = Target ("TARGET_ARM64", "TARGET_IOS", IOS_DEFINES)
self.target = Target ("TARGET_ARM64", ["TARGET_IOS", "TARGET_TVOS"], IOS_DEFINES)
self.target_args += ["-arch", "arm64"]
self.target_args += ["-isysroot", args.sysroot]
elif "i386-apple-darwin10" == args.abi:
require_sysroot (args)
self.target = Target ("TARGET_X86", "", IOS_DEFINES)
self.target_args += ["-arch", "i386"]
self.target_args += ["-isysroot", args.sysroot]
elif "x86_64-apple-darwin10" == args.abi:
require_sysroot (args)
self.target = Target ("TARGET_AMD64", "", IOS_DEFINES)
Expand Down Expand Up @@ -356,7 +349,10 @@ def gen (self):
if target.arch_define:
f.write ("#ifdef " + target.arch_define + "\n")
if target.platform_define:
f.write ("#ifdef " + target.platform_define + "\n")
if isinstance(target.platform_define, list):
f.write ("#if " + " || ".join (["defined (" + platform_define + ")" for platform_define in target.platform_define]) + "\n")
else:
f.write ("#ifdef " + target.platform_define + "\n")
f.write ("#ifndef HAVE_BOEHM_GC\n")
f.write ("#define HAS_CROSS_COMPILER_OFFSETS\n")
f.write ("#if defined (USE_CROSS_COMPILE_OFFSETS) || defined (MONO_CROSS_COMPILE)\n")
Expand Down Expand Up @@ -398,7 +394,10 @@ def gen (self):
if target.arch_define:
f.write ("#endif //" + target.arch_define + "\n")
if target.platform_define:
f.write ("#endif //" + target.platform_define + "\n")
if isinstance(target.platform_define, list):
f.write ("#endif //" + " || ".join (target.platform_define) + "\n")
else:
f.write ("#endif //" + target.platform_define + "\n")
f.write ("#endif //USED_CROSS_COMPILER_OFFSETS check\n")

tool = OffsetsTool ()
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/utils/atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,13 @@ mono_atomic_cas_i64(volatile gint64 *dest, gint64 exch, gint64 comp)
return gcc_sync_val_compare_and_swap (dest, comp, exch);
}

#elif defined (__arm__) && defined (HAVE_ARMV7) && (defined(TARGET_IOS) || defined(TARGET_WATCHOS) || defined(TARGET_ANDROID))
#elif defined (__arm__) && defined (HAVE_ARMV7) && (defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(TARGET_WATCHOS) || defined(TARGET_ANDROID))

#ifdef MONO_ATOMIC_USES_LOCK
#error MONO_ATOMIC_USES_LOCK defined
#endif

#if defined (TARGET_IOS) || defined (TARGET_WATCHOS)
#if defined (TARGET_IOS) || defined (TARGET_TVOS) || defined (TARGET_WATCHOS)

#ifndef __clang__
#error "Not supported."
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ mono_atomic_store_bool (volatile gboolean *dest, gboolean val)
#if defined (WAPI_NO_ATOMIC_ASM)
#define MONO_ATOMIC_USES_LOCK
#elif defined(BROKEN_64BIT_ATOMICS_INTRINSIC)
#if !defined(TARGET_OSX) && !(defined (__arm__) && defined (HAVE_ARMV7) && (defined(TARGET_IOS) || defined(TARGET_WATCHOS) || defined(TARGET_ANDROID)))
#if !defined(TARGET_OSX) && !(defined (__arm__) && defined (HAVE_ARMV7) && (defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(TARGET_WATCHOS) || defined(TARGET_ANDROID)))
#define MONO_ATOMIC_USES_LOCK
#endif
#endif
Expand Down
11 changes: 0 additions & 11 deletions src/mono/mono/utils/mono-dl-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ mono_dl_get_so_suffixes (void)
return suffixes;
}

const char*
mono_dl_get_system_dir (void)
{
#ifdef TARGET_IOS
/* IOS9 can't load system libraries using relative paths, i.e. 'libc' doesn't work, but '/usr/lib/libc' does. */
return "/usr/lib";
#else
return NULL;
#endif
}

#else

#include <mono/utils/mono-compiler.h>
Expand Down
6 changes: 0 additions & 6 deletions src/mono/mono/utils/mono-dl-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ mono_dl_get_so_suffixes (void)
return suffixes;
}

const char*
mono_dl_get_system_dir (void)
{
return NULL;
}

#endif

void *
Expand Down
7 changes: 0 additions & 7 deletions src/mono/mono/utils/mono-dl-wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ mono_dl_get_so_suffixes (void)
return suffixes;
}

const char*
mono_dl_get_system_dir (void)
{
return NULL;
}


void*
mono_dl_lookup_symbol (MonoDl *module, const char *name)
{
Expand Down
6 changes: 0 additions & 6 deletions src/mono/mono/utils/mono-dl-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@ mono_dl_current_error_string (void)
}
#endif /* HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE */

const char*
mono_dl_get_system_dir (void)
{
return NULL;
}

#else

#include <mono/utils/mono-compiler.h>
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/utils/mono-dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ void mono_dl_close_handle (MonoDl *module, MonoError *error);
void* mono_dl_lookup_symbol (MonoDl *module, const char *name);
int mono_dl_convert_flags (int mono_flags, int native_flags);
char* mono_dl_current_error_string (void);
const char* mono_dl_get_system_dir (void);

#endif /* __MONO_UTILS_DL_H__ */

2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-logger-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char *format, ...)
#define mono_trace_warning(...) (mono_trace (G_LOG_LEVEL_WARNING, __VA_ARGS__))
#define mono_trace_message(...) (mono_trace (G_LOG_LEVEL_MESSAGE, __VA_ARGS__))

#if defined (HOST_ANDROID) || (defined (TARGET_IOS) && defined (TARGET_IOS))
#if defined (HOST_ANDROID) || defined (TARGET_IOS) || defined (TARGET_TVOS)

#define mono_gc_printf(gc_log_file, format, ...) g_log ("mono-gc", G_LOG_LEVEL_MESSAGE, format, ##__VA_ARGS__)
#define mono_runtime_printf(format, ...) g_log ("mono-rt", G_LOG_LEVEL_MESSAGE, format "\n", ##__VA_ARGS__)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-sigcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define UCONTEXT_REG_EDI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_edi)
#define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_eip)
#elif defined(__APPLE__)
# if defined (TARGET_IOS) || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
# if defined (TARGET_IOS) || defined (TARGET_TVOS) || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
#define UCONTEXT_REG_EAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__eax)
#define UCONTEXT_REG_EBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__ebx)
#define UCONTEXT_REG_ECX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__ecx)
Expand Down

0 comments on commit b8653d9

Please sign in to comment.