From e3c4c7709f65404bcf8ce195a518e7d445e768d2 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Mon, 2 Nov 2026 02:07:38 +0800 Subject: Restructure libbase and RCCCore build --- rcc/CMakeLists.txt | 15 +-- rcc/cmake/modules/AddRCC.cmake | 14 +- rcc/include/rcc/Config/config.h.cmake | 215 +----------------------------- rcc/include/rcc/Config/rcc-config.h.cmake | 60 --------- rcc/include/rcc/DataTypes.h | 105 --------------- rcc/include/rcc/Support/Compiler.h | 106 +++++++++++++++ 6 files changed, 126 insertions(+), 389 deletions(-) delete mode 100644 rcc/include/rcc/DataTypes.h create mode 100644 rcc/include/rcc/Support/Compiler.h (limited to 'rcc') diff --git a/rcc/CMakeLists.txt b/rcc/CMakeLists.txt index 3825e8a..1fb86a0 100644 --- a/rcc/CMakeLists.txt +++ b/rcc/CMakeLists.txt @@ -53,20 +53,15 @@ configure_file( "${RCC_MAIN_INCLUDE_DIR}/rcc/Config/rcc-config.h.cmake" "${RCC_INCLUDE_DIR}/rcc/Config/rcc-config.h") -add_library(RCCHeaders INTERFACE) -target_compile_features(RCCHeaders INTERFACE cxx_std_23) -target_include_directories(RCCHeaders INTERFACE - "$" - "$" - "$") -install(TARGETS RCCHeaders EXPORT RCCTargets) install(DIRECTORY include/rcc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" PATTERN "*.def") -install(DIRECTORY "${RCC_BINARY_DIR}/include/rcc" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +install(DIRECTORY "${RCC_BINARY_DIR}/include/rcc/Config" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rcc" FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" PATTERN "*.def" - PATTERN "CMakeFiles" EXCLUDE PATTERN "config.h" EXCLUDE) + PATTERN "config.h" EXCLUDE) -add_subdirectory("${RCC_SOURCE_DIR}/../libsupport" "${CMAKE_CURRENT_BINARY_DIR}/libsupport") +set(RCC_LIBBASE_SOURCE_DIR "${RCC_SOURCE_DIR}/../libbase") +set(RCC_LIBBASE_BINARY_DIR "${RCC_BINARY_DIR}/libbase") +add_subdirectory("${RCC_LIBBASE_SOURCE_DIR}" "${RCC_LIBBASE_BINARY_DIR}") add_subdirectory(tools) foreach(rccProject IN LISTS RCC_ENABLE_PROJECTS) if(NOT rccProject STREQUAL "cfront") diff --git a/rcc/cmake/modules/AddRCC.cmake b/rcc/cmake/modules/AddRCC.cmake index 11bd92e..738df5f 100644 --- a/rcc/cmake/modules/AddRCC.cmake +++ b/rcc/cmake/modules/AddRCC.cmake @@ -162,7 +162,13 @@ endfunction() function(add_rcc_library name) cmake_parse_arguments(PARSE_ARGV 1 arg "DISABLE_PCH_REUSE;NO_INSTALL_RPATH" "" "LINK_LIBS;PRECOMPILE_HEADERS") add_library(${name} ${arg_UNPARSED_ARGUMENTS}) - target_link_libraries(${name} PUBLIC RCCHeaders ${arg_LINK_LIBS}) + target_link_libraries(${name} PUBLIC RCCCore ${arg_LINK_LIBS}) + target_compile_features(${name} PUBLIC cxx_std_23) + target_compile_definitions(${name} PRIVATE RCC_EXPORTS) + target_include_directories(${name} PUBLIC + "$" + "$" + "$") rcc_configure_target(${name}) install(TARGETS ${name} EXPORT RCCTargets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -173,7 +179,11 @@ endfunction() function(add_rcc_executable name) cmake_parse_arguments(PARSE_ARGV 1 arg "DISABLE_PCH_REUSE;NO_INSTALL_RPATH" "" "LINK_LIBS;PRECOMPILE_HEADERS") add_executable(${name} ${arg_UNPARSED_ARGUMENTS}) - target_link_libraries(${name} PRIVATE RCCHeaders ${arg_LINK_LIBS}) + target_link_libraries(${name} PRIVATE RCCCore ${arg_LINK_LIBS}) + target_compile_features(${name} PRIVATE cxx_std_23) + target_include_directories(${name} PRIVATE + "${RCC_SOURCE_DIR}/include" + "${RCC_BINARY_DIR}/include") rcc_configure_target(${name}) endfunction() diff --git a/rcc/include/rcc/Config/config.h.cmake b/rcc/include/rcc/Config/config.h.cmake index 32761c1..8830412 100644 --- a/rcc/include/rcc/Config/config.h.cmake +++ b/rcc/include/rcc/Config/config.h.cmake @@ -1,5 +1,5 @@ -#ifndef CONFIG_H -#define CONFIG_H +#ifndef RCC_PRIVATE_CONFIG_H +#define RCC_PRIVATE_CONFIG_H // Include this header only under the rcc source tree. // This is a private header. @@ -10,38 +10,6 @@ /* Bug report URL. */ #define BUG_REPORT_URL "${BUG_REPORT_URL}" -/* Define to 1 to enable backtraces, and to 0 otherwise. */ -#cmakedefine01 ENABLE_BACKTRACES - -/* Define to 1 to enable crash overrides, and to 0 otherwise. */ -#cmakedefine01 ENABLE_CRASH_OVERRIDES - -/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */ -#cmakedefine01 RCC_ENABLE_CRASH_DUMPS - -/* Define to 1 to prefer forward slashes on Windows, and to 0 prefer - backslashes. */ -#cmakedefine01 RCC_WINDOWS_PREFER_FORWARD_SLASH - -/* Define to 1 if you have the `backtrace' function. */ -#cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE} - -#define BACKTRACE_HEADER <${BACKTRACE_HEADER}> - -/* can use __crashreporter_info__ */ -#cmakedefine01 HAVE_CRASHREPORTER_INFO - -/* Define to 1 if you have the declaration of `arc4random', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_ARC4RANDOM - -/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_STRERROR_S - -/* Define if dlopen() is available on this platform. */ -#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN} - /* Define to 1 if we can register EH frames on this platform. */ #cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME} @@ -60,177 +28,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FFI_H ${HAVE_FFI_H} -/* Define to 1 if you have the `futimens' function. */ -#cmakedefine HAVE_FUTIMENS ${HAVE_FUTIMENS} - -/* Define to 1 if you have the `futimes' function. */ -#cmakedefine HAVE_FUTIMES ${HAVE_FUTIMES} - -/* Define to 1 if you have the `getpagesize' function. */ -#cmakedefine HAVE_GETPAGESIZE ${HAVE_GETPAGESIZE} - -/* Define to 1 if you have the `getrusage' function. */ -#cmakedefine HAVE_GETRUSAGE ${HAVE_GETRUSAGE} - -/* Define to 1 if you have the `isatty' function. */ -#cmakedefine HAVE_ISATTY 1 - -/* Define to 1 if you have the `edit' library (-ledit). */ -#cmakedefine HAVE_LIBEDIT ${HAVE_LIBEDIT} - /* Define to 1 if you have the `pfm' library (-lpfm). */ #cmakedefine HAVE_LIBPFM ${HAVE_LIBPFM} /* Define to 1 if the `perf_branch_entry' struct has field cycles. */ #cmakedefine LIBPFM_HAS_FIELD_CYCLES ${LIBPFM_HAS_FIELD_CYCLES} -/* Define to 1 if you have the `psapi' library (-lpsapi). */ -#cmakedefine HAVE_LIBPSAPI ${HAVE_LIBPSAPI} - -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#cmakedefine HAVE_LIBPTHREAD ${HAVE_LIBPTHREAD} - -/* Define to 1 if you have the `pthread_getname_np' function. */ -#cmakedefine HAVE_PTHREAD_GETNAME_NP ${HAVE_PTHREAD_GETNAME_NP} - -/* Define to 1 if you have the `pthread_setname_np' function. */ -#cmakedefine HAVE_PTHREAD_SETNAME_NP ${HAVE_PTHREAD_SETNAME_NP} - -/* Define to 1 if you have the `pthread_get_name_np' function. */ -#cmakedefine HAVE_PTHREAD_GET_NAME_NP ${HAVE_PTHREAD_GET_NAME_NP} - -/* Define to 1 if you have the `pthread_set_name_np' function. */ -#cmakedefine HAVE_PTHREAD_SET_NAME_NP ${HAVE_PTHREAD_SET_NAME_NP} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MACH_MACH_H ${HAVE_MACH_MACH_H} - -/* Define to 1 if you have the `mallctl' function. */ -#cmakedefine HAVE_MALLCTL ${HAVE_MALLCTL} - -/* Define to 1 if you have the `mallinfo' function. */ -#cmakedefine HAVE_MALLINFO ${HAVE_MALLINFO} - -/* Define to 1 if you have the `mallinfo2' function. */ -#cmakedefine HAVE_MALLINFO2 ${HAVE_MALLINFO2} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MALLOC_MALLOC_H ${HAVE_MALLOC_MALLOC_H} - -/* Define to 1 if you have the `malloc_zone_statistics' function. */ -#cmakedefine HAVE_MALLOC_ZONE_STATISTICS ${HAVE_MALLOC_ZONE_STATISTICS} - -/* Define to 1 if you have the `posix_spawn' function. */ -#cmakedefine HAVE_POSIX_SPAWN ${HAVE_POSIX_SPAWN} - -/* Define to 1 if you have the `pread' function. */ -#cmakedefine HAVE_PREAD ${HAVE_PREAD} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_PTHREAD_H ${HAVE_PTHREAD_H} - -/* Have pthread_rwlock_init */ -#cmakedefine HAVE_PTHREAD_RWLOCK_INIT ${HAVE_PTHREAD_RWLOCK_INIT} - -/* Define to 1 if you have the `sbrk' function. */ -#cmakedefine HAVE_SBRK ${HAVE_SBRK} - -/* Define to 1 if you have the `setenv' function. */ -#cmakedefine HAVE_SETENV ${HAVE_SETENV} - -/* Define to 1 if you have the `sigaltstack' function. */ -#cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK} - -/* Define to 1 if you have the `strerror_r' function. */ -#cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R} - -/* Define to 1 if you have the `sysconf' function. */ -#cmakedefine HAVE_SYSCONF ${HAVE_SYSCONF} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_IOCTL_H ${HAVE_SYS_IOCTL_H} - -/* Define to 1 if stat struct has st_mtimespec member .*/ -#cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC} - -/* Define to 1 if stat struct has st_mtim member. */ -#cmakedefine HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} - -/* Have host's _alloca */ -#cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA} - -/* Define to 1 if you have the `_chsize_s' function. */ -#cmakedefine HAVE__CHSIZE_S ${HAVE__CHSIZE_S} - -/* Define to 1 if you have the `_Unwind_Backtrace' function. */ -#cmakedefine HAVE__UNWIND_BACKTRACE ${HAVE__UNWIND_BACKTRACE} - -/* Have host's __alloca */ -#cmakedefine HAVE___ALLOCA ${HAVE___ALLOCA} - -/* Have host's __ashldi3 */ -#cmakedefine HAVE___ASHLDI3 ${HAVE___ASHLDI3} - -/* Have host's __ashrdi3 */ -#cmakedefine HAVE___ASHRDI3 ${HAVE___ASHRDI3} - -/* Have host's __chkstk */ -#cmakedefine HAVE___CHKSTK ${HAVE___CHKSTK} - -/* Have host's __chkstk_ms */ -#cmakedefine HAVE___CHKSTK_MS ${HAVE___CHKSTK_MS} - -/* Have host's __cmpdi2 */ -#cmakedefine HAVE___CMPDI2 ${HAVE___CMPDI2} - -/* Have host's __divdi3 */ -#cmakedefine HAVE___DIVDI3 ${HAVE___DIVDI3} - -/* Have host's __fixdfdi */ -#cmakedefine HAVE___FIXDFDI ${HAVE___FIXDFDI} - -/* Have host's __fixsfdi */ -#cmakedefine HAVE___FIXSFDI ${HAVE___FIXSFDI} - -/* Have host's __floatdidf */ -#cmakedefine HAVE___FLOATDIDF ${HAVE___FLOATDIDF} - -/* Have host's __lshrdi3 */ -#cmakedefine HAVE___LSHRDI3 ${HAVE___LSHRDI3} - -/* Have host's __main */ -#cmakedefine HAVE___MAIN ${HAVE___MAIN} - -/* Have host's __moddi3 */ -#cmakedefine HAVE___MODDI3 ${HAVE___MODDI3} - -/* Have host's __udivdi3 */ -#cmakedefine HAVE___UDIVDI3 ${HAVE___UDIVDI3} - -/* Have host's __umoddi3 */ -#cmakedefine HAVE___UMODDI3 ${HAVE___UMODDI3} - -/* Have host's ___chkstk */ -#cmakedefine HAVE____CHKSTK ${HAVE____CHKSTK} - -/* Have host's ___chkstk_ms */ -#cmakedefine HAVE____CHKSTK_MS ${HAVE____CHKSTK_MS} - -/* Define if ICU library is available */ -#cmakedefine01 HAVE_ICU - -/* Define if Windows vendored ICU is available */ -#cmakedefine01 HAVE_WINDOWS_ICU - -/* Define if iconv library is available */ -#cmakedefine01 HAVE_ICONV - /* Linker version detected at compile time. */ #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}" @@ -267,25 +70,13 @@ /* Define to the vendor of this package. */ #cmakedefine PACKAGE_VENDOR "${PACKAGE_VENDOR}" -/* Define to a function implementing stricmp */ -#cmakedefine stricmp ${stricmp} - -/* Define to a function implementing strdup */ -#cmakedefine strdup ${strdup} - /* Whether GlobalISel rule coverage is being collected */ #cmakedefine01 RCC_GISEL_COV_ENABLED /* Define to the default GlobalISel coverage file prefix */ #cmakedefine RCC_GISEL_COV_PREFIX "${RCC_GISEL_COV_PREFIX}" -/* Whether Timers signpost passes in Xcode Instruments */ -#cmakedefine01 RCC_SUPPORT_XCODE_SIGNPOSTS - -#cmakedefine HAVE_PROC_PID_RUSAGE 1 - +/* Have host's builtin thread pointer. */ #cmakedefine HAVE_BUILTIN_THREAD_POINTER ${HAVE_BUILTIN_THREAD_POINTER} -#cmakedefine HAVE_GETAUXVAL ${HAVE_GETAUXVAL} - #endif diff --git a/rcc/include/rcc/Config/rcc-config.h.cmake b/rcc/include/rcc/Config/rcc-config.h.cmake index 9c0ba18..fb76d22 100644 --- a/rcc/include/rcc/Config/rcc-config.h.cmake +++ b/rcc/include/rcc/Config/rcc-config.h.cmake @@ -14,19 +14,10 @@ #ifndef RCC_CONFIG_H #define RCC_CONFIG_H -/* Define if RCC_ENABLE_DUMP is enabled */ -#cmakedefine RCC_ENABLE_DUMP - /* Target triple RCC will generate code for by default */ /* Doesn't use `cmakedefine` because it is allowed to be empty. */ #define RCC_DEFAULT_TARGET_TRIPLE "${RCC_DEFAULT_TARGET_TRIPLE}" -/* Define if threads enabled */ -#cmakedefine01 RCC_ENABLE_THREADS - -/* Has gcc/MSVC atomic intrinsics */ -#cmakedefine01 RCC_HAS_ATOMICS - /* Host triple RCC will be executed on */ #cmakedefine RCC_HOST_TRIPLE "${RCC_HOST_TRIPLE}" @@ -54,9 +45,6 @@ /* RCC name for the native target MCA init function, if available */ #cmakedefine RCC_NATIVE_TARGETMCA RCCInitialize${RCC_NATIVE_ARCH}TargetMCA -/* Define if this is Unixish platform */ -#cmakedefine RCC_ON_UNIX ${RCC_ON_UNIX} - /* Define if we have the Intel JIT API runtime support library */ #cmakedefine01 RCC_USE_INTEL_JITEVENTS @@ -78,69 +66,24 @@ /* RCC version string */ #define RCC_VERSION_STRING "${PACKAGE_VERSION}" -/* Whether RCC records statistics for use with GetStatistics(), - * PrintStatistics() or PrintStatisticsJSON() - */ -#cmakedefine01 RCC_FORCE_ENABLE_STATS - -/* Define if we have z3 and want to build it */ -#cmakedefine RCC_WITH_Z3 ${RCC_WITH_Z3} - -/* Define if we have curl and want to use it */ -#cmakedefine RCC_ENABLE_CURL ${RCC_ENABLE_CURL} - -/* Define if we have cpp-httplib and want to use it */ -#cmakedefine RCC_ENABLE_HTTPLIB ${RCC_ENABLE_HTTPLIB} - -/* Define if zlib compression is available */ -#cmakedefine01 RCC_ENABLE_ZLIB - -/* Define if zstd compression is available */ -#cmakedefine01 RCC_ENABLE_ZSTD - -/* Define if xz (lzma) decompression is available */ -#cmakedefine01 RCC_ENABLE_LZMA - /* Define if RCC is using tflite */ #cmakedefine RCC_HAVE_TFLITE /* Define if we want to check profile consistency in lit tests */ #cmakedefine RCC_ENABLE_PROFCHECK -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} - /* Define if building libRCC shared library */ #cmakedefine RCC_BUILD_RCC_DYLIB -/* Define if building RCC with BUILD_SHARED_LIBS */ -#cmakedefine RCC_BUILD_SHARED_LIBS - -/* Define if exporting RCC public interface for shared library */ -#cmakedefine RCC_ENABLE_RCC_EXPORT_ANNOTATIONS - /* Define if exporting RCC-C public interface for shared library */ #cmakedefine RCC_ENABLE_RCC_C_EXPORT_ANNOTATIONS -/* Define if building RCC with RCC_FORCE_USE_OLD_TOOLCHAIN_LIBS */ -#cmakedefine RCC_FORCE_USE_OLD_TOOLCHAIN ${RCC_FORCE_USE_OLD_TOOLCHAIN} - -/* Define if rcc_unreachable should be optimized with undefined behavior - * in non assert builds */ -#cmakedefine01 RCC_UNREACHABLE_OPTIMIZE - -/* Define if building RCC with RCC_ENABLE_IO_SANDBOX */ -#cmakedefine01 RCC_ENABLE_IO_SANDBOX - /* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */ #cmakedefine01 RCC_ENABLE_DIA_SDK /* Define if plugins enabled */ #cmakedefine RCC_ENABLE_PLUGINS -/* Define if logf128 is available */ -#cmakedefine RCC_HAS_LOGF128 - /* Define if building RCC with RCC_ENABLE_TELEMETRY */ #cmakedefine01 RCC_ENABLE_TELEMETRY @@ -152,7 +95,4 @@ coverage bugs, and to 0 otherwise. */ #cmakedefine01 RCC_ENABLE_DEBUGLOC_TRACKING_ORIGIN -/* Define to 1 to enable RCC OnDisk Content Addressable Storage */ -#cmakedefine01 RCC_ENABLE_ONDISK_CAS - #endif diff --git a/rcc/include/rcc/DataTypes.h b/rcc/include/rcc/DataTypes.h deleted file mode 100644 index 59e9b75..0000000 --- a/rcc/include/rcc/DataTypes.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - RCC-Project - - Copyright (C) 2026 Richard Qin - - This file is part of RCC-Project. - - RCC-Project is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 3, or (at your option) any later - version. - - RCC-Project is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - -You should have received a copy of the GNU General Public License -along with RCC-Project; see the file COPYING. If not see -. -*/ - -// This implementation is based on include/llvm-c/DataTypes.h -/*===-- include/llvm-c/DataTypes.h - Define fixed size types ------*- C -*-===*\ - | * *|* - |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| - |* Exceptions. *| - |* See https://llvm.org/LICENSE.txt for license information. *| - |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| - |* *| - |*===----------------------------------------------------------------------===*| - |* *| - |* This file contains definitions to figure out the size of _HOST_ data - types.*| - |* This file is important because different host OS's define different - macros,*| - |* which makes portability tough. This file exports the following *| - |* definitions: *| - |* *| - |* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system - types*| - |* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *| - |* *| - |* No library is required when using these functions. *| - |* *| - |*===----------------------------------------------------------------------===*/ - -/* Please leave this file C-compatible. */ -#ifndef RCC_DATATYPES_H -#define RCC_DATATYPES_H - -#include -#include - -#ifndef _MSC_VER - -#if !defined(UINT32_MAX) -#error "The standard header is not C++11 compliant. Must #define "\ - "__STDC_LIMIT_MACROS before #including llvm-c/DataTypes.h" -#endif - -#if !defined(UINT32_C) -#error "The standard header is not C++11 compliant. Must #define "\ - "__STDC_CONSTANT_MACROS before #including llvm-c/DataTypes.h" -#endif - -/* Note that includes , if this is a C99 system. */ -#include - -#ifdef _AIX -// GCC is strict about defining large constants: they must have LL modifier. -#undef INT64_MAX -#undef INT64_MIN -#endif - -#else /* _MSC_VER */ -#ifdef __cplusplus -#include -#include -#else -#include -#include -#endif -#include - -#if defined(_WIN64) -typedef signed __int64 ssize_t; -#else -typedef signed int ssize_t; -#endif /* _WIN64 */ - -#endif /* _MSC_VER */ - -/* Set defaults for constants which we cannot find. */ -#if !defined(INT64_MAX) -#define INT64_MAX 9223372036854775807LL -#endif -#if !defined(INT64_MIN) -#define INT64_MIN ((-INT64_MAX) - 1) -#endif -#if !defined(UINT64_MAX) -#define UINT64_MAX 0xffffffffffffffffULL -#endif - -#endif diff --git a/rcc/include/rcc/Support/Compiler.h b/rcc/include/rcc/Support/Compiler.h new file mode 100644 index 0000000..1076827 --- /dev/null +++ b/rcc/include/rcc/Support/Compiler.h @@ -0,0 +1,106 @@ +/* + RCC-Project + + Copyright (C) 2026 Richard Qin + + This file is part of RCC-Project. + + RCC-Project is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) any + later version. + + RCC-Project is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + RCC-Project; see the file COPYING. If not see + . +*/ + +//===-- rcc/Support/Compiler.h - RCC ABI support ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef RCC_SUPPORT_COMPILER_H +#define RCC_SUPPORT_COMPILER_H + +#include "core/compiler/Compiler.h" +#include "rcc/Config/rcc-config.h" + +/// RCC_EXTERNAL_VISIBILITY - classes, functions, and variables marked with +/// this attribute will be made public and visible outside of a shared library. +#if defined(RCC_BUILD_RCC_DYLIB) || defined(RCC_BUILD_SHARED_LIBS) +#define RCC_EXTERNAL_VISIBILITY LIBBASE_ATTRIBUTE_VISIBILITY_DEFAULT +#else +#define RCC_EXTERNAL_VISIBILITY +#endif + +/// RCC_LIBRARY_VISIBILITY - Mark symbols private to the RCC shared library. +#if (!(defined(_WIN32) || defined(__CYGWIN__)) || \ + ((defined(__MINGW32__) || defined(__CYGWIN__)) && defined(__clang__))) +#define RCC_LIBRARY_VISIBILITY LIBBASE_ATTRIBUTE_VISIBILITY_HIDDEN +#if defined(__clang__) && __clang_major__ < 15 +#define RCC_LIBRARY_VISIBILITY_NAMESPACE [[gnu::visibility("hidden")]] +#else +#define RCC_LIBRARY_VISIBILITY_NAMESPACE LIBBASE_ATTRIBUTE_VISIBILITY_HIDDEN +#endif +#define RCC_ALWAYS_EXPORT LIBBASE_ATTRIBUTE_VISIBILITY_DEFAULT +#elif defined(_WIN32) +#define RCC_ALWAYS_EXPORT __declspec(dllexport) +#define RCC_LIBRARY_VISIBILITY +#define RCC_LIBRARY_VISIBILITY_NAMESPACE +#else +#define RCC_LIBRARY_VISIBILITY +#define RCC_ALWAYS_EXPORT +#define RCC_LIBRARY_VISIBILITY_NAMESPACE +#endif + +/// RCC_ABI is the main export macro for the RCC public interface. +/// RCC_ABI_EXPORT always exports a symbol from the defining library. +/// RCC_EXPORT_TEMPLATE marks explicit template instantiations. +/// RCC_TEMPLATE_ABI marks extern template declarations. +#ifndef RCC_ABI_GENERATING_ANNOTATIONS +#define RCC_ABI_NOT_EXPORTED +#if defined(RCC_ENABLE_RCC_EXPORT_ANNOTATIONS) && !defined(RCC_BUILD_STATIC) +#if defined(_WIN32) && !defined(__MINGW32__) +#if defined(RCC_EXPORTS) +#define RCC_ABI __declspec(dllexport) +#define RCC_TEMPLATE_ABI +#define RCC_EXPORT_TEMPLATE __declspec(dllexport) +#else +#define RCC_ABI __declspec(dllimport) +#define RCC_TEMPLATE_ABI __declspec(dllimport) +#define RCC_EXPORT_TEMPLATE +#endif +#define RCC_ABI_EXPORT __declspec(dllexport) +#elif __has_attribute(visibility) +#if defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) || \ + defined(__MVS__) || defined(__CYGWIN__) +#define RCC_ABI LIBBASE_ATTRIBUTE_VISIBILITY_DEFAULT +#define RCC_TEMPLATE_ABI RCC_ABI +#define RCC_EXPORT_TEMPLATE +#define RCC_ABI_EXPORT RCC_ABI +#elif defined(__MACH__) || defined(__wasm__) || defined(__EMSCRIPTEN__) +#define RCC_ABI LIBBASE_ATTRIBUTE_VISIBILITY_DEFAULT +#define RCC_TEMPLATE_ABI +#define RCC_EXPORT_TEMPLATE +#define RCC_ABI_EXPORT RCC_ABI +#endif +#endif +#endif +#if !defined(RCC_ABI) +#define RCC_ABI +#define RCC_TEMPLATE_ABI +#define RCC_EXPORT_TEMPLATE +#define RCC_ABI_EXPORT +#endif +#define RCC_ABI_FOR_TEST RCC_ABI +#endif + +#endif -- cgit v1.2.3