Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share compiler configurations across libs & coreclr #58096

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 89 additions & 59 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

# "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set.
Expand Down Expand Up @@ -162,6 +163,13 @@ elseif (CLR_CMAKE_HOST_UNIX)
add_linker_flag("-Wl,--gc-sections" DEBUG CHECKED)
endif ()
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)

if(CLR_CMAKE_HOST_BROWSER)
# The emscripten build has additional warnings so -Werror breaks
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-alloca)
add_compile_options(-Wno-implicit-int-float-conversion)
lambdageek marked this conversation as resolved.
Show resolved Hide resolved
endif()
endif(MSVC)

# CLR_ADDITIONAL_LINKER_FLAGS - used for passing additional arguments to linker
Expand All @@ -187,18 +195,18 @@ elseif(CLR_CMAKE_HOST_SUNOS)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
add_definitions(-D__EXTENSIONS__)
elseif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
add_definitions(-D__EXTENSIONS__ -D_XPG4_2 -D_POSIX_PTHREAD_SEMANTICS)
elseif(CLR_CMAKE_HOST_OSX AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
add_definitions(-D_XOPEN_SOURCE)
add_linker_flag("-Wl,-bind_at_load")
endif()

#------------------------------------
# Definitions (for platform)
#-----------------------------------
if (CLR_CMAKE_HOST_ARCH_AMD64)
set(ARCH_HOST_NAME x64)
add_definitions(-DHOST_AMD64)
add_definitions(-DHOST_64BIT)
add_definitions(-DHOST_AMD64 -DHOST_64BIT)
elseif (CLR_CMAKE_HOST_ARCH_I386)
set(ARCH_HOST_NAME x86)
add_definitions(-DHOST_X86)
Expand All @@ -207,12 +215,16 @@ elseif (CLR_CMAKE_HOST_ARCH_ARM)
add_definitions(-DHOST_ARM)
elseif (CLR_CMAKE_HOST_ARCH_ARM64)
set(ARCH_HOST_NAME arm64)
add_definitions(-DHOST_ARM64)
add_definitions(-DHOST_64BIT)
add_definitions(-DHOST_ARM64 -DHOST_64BIT)
elseif (CLR_CMAKE_HOST_ARCH_S390X)
set(ARCH_HOST_NAME s390x)
add_definitions(-DHOST_S390X)
add_definitions(-DHOST_64BIT)
add_definitions(-DHOST_S390X -DHOST_64BIT -DBIGENDIAN)
am11 marked this conversation as resolved.
Show resolved Hide resolved
elseif (CLR_CMAKE_HOST_ARCH_WASM)
set(ARCH_HOST_NAME wasm)
add_definitions(-DHOST_WASM -DHOST_32BIT=1)
elseif (CLR_CMAKE_HOST_ARCH_MIPS64)
set(ARCH_HOST_NAME mips64)
add_definitions(-DHOST_MIPS64 -DHOST_64BIT=1)
else ()
clr_unknown_arch()
endif ()
Expand Down Expand Up @@ -265,6 +277,9 @@ if (CLR_CMAKE_HOST_WIN32)
set(STATIC_MT_CPP_LIB "libcpmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
endif(CLR_CMAKE_HOST_WIN32)

# Unconditionally define _FILE_OFFSET_BITS as 64 on all platforms.
add_definitions(-D_FILE_OFFSET_BITS=64)

# Architecture specific files folder name
if (CLR_CMAKE_TARGET_ARCH_AMD64)
set(ARCH_SOURCES_DIR amd64)
Expand All @@ -280,15 +295,27 @@ elseif (CLR_CMAKE_TARGET_ARCH_ARM)
set(ARCH_SOURCES_DIR arm)
set(ARCH_TARGET_NAME arm)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_ARM>)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_32BIT>)
elseif (CLR_CMAKE_TARGET_ARCH_I386)
set(ARCH_TARGET_NAME x86)
set(ARCH_SOURCES_DIR i386)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_X86>)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_32BIT>)
elseif (CLR_CMAKE_TARGET_ARCH_S390X)
set(ARCH_TARGET_NAME s390x)
set(ARCH_SOURCES_DIR s390x)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_S390X>)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
elseif (CLR_CMAKE_TARGET_ARCH_WASM)
set(ARCH_TARGET_NAME wasm)
set(ARCH_SOURCES_DIR wasm)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_WASM>)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_32BIT>)
elseif (CLR_CMAKE_TARGET_ARCH_MIPS64)
set(ARCH_TARGET_NAME mips64)
set(ARCH_SOURCES_DIR mips64)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_MIPS64>)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
else ()
clr_unknown_arch()
endif ()
Expand All @@ -312,8 +339,8 @@ if (CLR_CMAKE_HOST_UNIX)
if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
# We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
add_compile_options(-fstack-protector)
else()
check_cxx_compiler_flag(-fstack-protector-strong COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG)
elseif(NOT CLR_CMAKE_HOST_BROWSER)
check_c_compiler_flag(-fstack-protector-strong COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG)
if (COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG)
add_compile_options(-fstack-protector-strong)
endif()
Expand All @@ -329,16 +356,20 @@ if (CLR_CMAKE_HOST_UNIX)
add_compile_options(-Wno-unused-value)
add_compile_options(-Wno-unused-function)
add_compile_options(-Wno-tautological-compare)
add_compile_options(-Wno-unknown-pragmas)

check_cxx_compiler_flag(-Wimplicit-fallthrough COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH)
# Explicitly enabled warnings
check_c_compiler_flag(-Wimplicit-fallthrough COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH)
if (COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH)
add_compile_options(-Wimplicit-fallthrough)
endif()

#These seem to indicate real issues
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-unknown-warning-option)

# The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
# after hitting just about 20 errors.
add_compile_options(-ferror-limit=4096)
Expand All @@ -355,22 +386,23 @@ if (CLR_CMAKE_HOST_UNIX)
# a header file.
add_compile_options(-Wno-pragma-pack)

add_compile_options(-Wno-unknown-warning-option)

# The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
# to a struct or a class that has virtual members or a base class. In that case, clang
# may not generate the same object layout as MSVC.
add_compile_options(-Wno-incompatible-ms-struct)
else()
add_compile_options(-Wno-unused-but-set-variable)
add_compile_options(-Wno-unknown-pragmas)
add_compile_options(-Wno-uninitialized)
add_compile_options(-Wno-strict-aliasing)
add_compile_options(-Wno-array-bounds)
check_cxx_compiler_flag(-Wclass-memaccess COMPILER_SUPPORTS_W_CLASS_MEMACCESS)
if (COMPILER_SUPPORTS_W_CLASS_MEMACCESS)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>)
endif()
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-misleading-indentation>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-overflow>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-truncation>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-mismatched-new-delete>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-free-nonheap-object>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-placement-new>)

check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW)
if (COMPILER_SUPPORTS_F_ALIGNED_NEW)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-faligned-new>)
Expand All @@ -385,62 +417,60 @@ if (CLR_CMAKE_HOST_UNIX)
add_compile_options(-fvisibility=hidden)

# Specify the minimum supported version of macOS
if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
# Mac Catalyst needs a special CFLAG, exclusive with mmacosx-version-min
if(CLR_CMAKE_TARGET_MACCATALYST)
# Somewhere between CMake 3.17 and 3.19.4, it became impossible to not pass
# a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
# replaced with a default value, and always gets expanded to an OS version.
# https://gitlab.kitware.com/cmake/cmake/-/issues/20132
# We need to disable the warning that -tagret replaces -mmacosx-version-min
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
add_link_options(-Wno-overriding-t-option)
if(CLR_CMAKE_HOST_ARCH_ARM64)
set(MACOS_VERSION_MIN_FLAGS "-target arm64-apple-ios14.2-macabi")
add_link_options(-target arm64-apple-ios14.2-macabi)
elseif(CLR_CMAKE_HOST_ARCH_AMD64)
set(MACOS_VERSION_MIN_FLAGS "-target x86_64-apple-ios13.5-macabi")
add_link_options(-target x86_64-apple-ios13.5-macabi)
else()
clr_unknown_arch()
endif()
# These options are intentionally set using the CMAKE_XXX_FLAGS instead of
# add_compile_options so that they take effect on the configuration functions
# in various configure.cmake files.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
# Mac Catalyst needs a special CFLAG, exclusive with mmacosx-version-min
if(CLR_CMAKE_HOST_MACCATALYST)
# Somewhere between CMake 3.17 and 3.19.4, it became impossible to not pass
# a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets
# replaced with a default value, and always gets expanded to an OS version.
# https://gitlab.kitware.com/cmake/cmake/-/issues/20132
# We need to disable the warning that -tagret replaces -mmacosx-version-min
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
add_link_options(-Wno-overriding-t-option)
if(CLR_CMAKE_HOST_ARCH_ARM64)
set(MACOS_VERSION_MIN_FLAGS "-target arm64-apple-ios14.2-macabi")
add_link_options(-target arm64-apple-ios14.2-macabi)
elseif(CLR_CMAKE_HOST_ARCH_AMD64)
set(MACOS_VERSION_MIN_FLAGS "-target x86_64-apple-ios13.5-macabi")
add_link_options(-target x86_64-apple-ios13.5-macabi)
else()
if(CLR_CMAKE_HOST_ARCH_ARM64)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
add_compile_options(-arch arm64)
elseif(CLR_CMAKE_HOST_ARCH_AMD64)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
add_compile_options(-arch x86_64)
else()
clr_unknown_arch()
endif()
endif(CLR_CMAKE_TARGET_MACCATALYST)
endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
clr_unknown_arch()
endif()
# These options are intentionally set using the CMAKE_XXX_FLAGS instead of
# add_compile_options so that they take effect on the configuration functions
# in various configure.cmake files.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
elseif(CLR_CMAKE_HOST_OSX)
if(CLR_CMAKE_HOST_ARCH_ARM64)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
add_compile_options(-arch arm64)
elseif(CLR_CMAKE_HOST_ARCH_AMD64)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
add_compile_options(-arch x86_64)
else()
clr_unknown_arch()
endif()
endif(CLR_CMAKE_HOST_MACCATALYST)

endif(CLR_CMAKE_HOST_UNIX)

if(CLR_CMAKE_TARGET_UNIX)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_UNIX>)
# Contracts are disabled on UNIX.
add_definitions(-DDISABLE_CONTRACTS)
if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST)
if(CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_OSX>)
elseif(CLR_CMAKE_TARGET_FREEBSD)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_FREEBSD>)
elseif(CLR_CMAKE_TARGET_ANDROID)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_ANDROID>)
elseif(CLR_CMAKE_TARGET_LINUX)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_LINUX>)
elseif(CLR_CMAKE_TARGET_NETBSD)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_NETBSD>)
elseif(CLR_CMAKE_TARGET_SUNOS)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_SUNOS>)
elseif(CLR_CMAKE_TARGET_ANDROID)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_ANDROID>)
endif()
else(CLR_CMAKE_TARGET_UNIX)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_WINDOWS>)
Expand Down Expand Up @@ -664,7 +694,7 @@ if (CLR_CMAKE_HOST_WIN32)
message(FATAL_ERROR "MC not found")
endif()

else (CLR_CMAKE_HOST_WIN32)
elseif (NOT CLR_CMAKE_HOST_BROWSER)
enable_language(ASM)

endif(CLR_CMAKE_HOST_WIN32)
14 changes: 11 additions & 3 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux)
set(CLR_CMAKE_HOST_UNIX_X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390x)
set(CLR_CMAKE_HOST_UNIX_S390X 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL mips64)
set(CLR_CMAKE_HOST_UNIX_MIPS64 1)
else()
clr_unknown_arch()
endif()
Expand Down Expand Up @@ -191,8 +193,7 @@ if(CLR_CMAKE_HOST_OS STREQUAL Windows)
endif(CLR_CMAKE_HOST_OS STREQUAL Windows)

if(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
#set(CLR_CMAKE_HOST_UNIX 1) # TODO: this should be reenabled but it activates a bunch of additional compiler flags in configurecompiler.cmake
set(CLR_CMAKE_HOST_UNIX_WASM 1)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_BROWSER 1)
endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten)

Expand Down Expand Up @@ -226,9 +227,12 @@ elseif(CLR_CMAKE_HOST_UNIX_X86)
elseif(CLR_CMAKE_HOST_UNIX_S390X)
set(CLR_CMAKE_HOST_ARCH_S390X 1)
set(CLR_CMAKE_HOST_ARCH "s390x")
elseif(CLR_CMAKE_HOST_UNIX_WASM)
elseif(CLR_CMAKE_HOST_BROWSER)
set(CLR_CMAKE_HOST_ARCH_WASM 1)
set(CLR_CMAKE_HOST_ARCH "wasm")
elseif(CLR_CMAKE_HOST_UNIX_MIPS64)
set(CLR_CMAKE_HOST_ARCH_MIPS64 1)
set(CLR_CMAKE_HOST_ARCH "mips64")
elseif(WIN32)
# CLR_CMAKE_HOST_ARCH is passed in as param to cmake
if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
Expand Down Expand Up @@ -274,6 +278,8 @@ if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
set(CLR_CMAKE_TARGET_ARCH_S390X 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
set(CLR_CMAKE_TARGET_ARCH_WASM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64)
set(CLR_CMAKE_TARGET_ARCH_MIPS64 1)
else()
clr_unknown_arch()
endif()
Expand Down Expand Up @@ -374,6 +380,8 @@ if(CLR_CMAKE_TARGET_UNIX)
set(CLR_CMAKE_TARGET_UNIX_S390X 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
set(CLR_CMAKE_TARGET_UNIX_WASM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64)
set(CLR_CMAKE_TARGET_UNIX_MIPS64 1)
else()
clr_unknown_arch()
endif()
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ endif(CORECLR_SET_RPATH)

OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)

if(CLR_CMAKE_HOST_ARCH_S390X)
add_definitions(-DBIGENDIAN)
endif(CLR_CMAKE_HOST_ARCH_S390X)

#----------------------------------------------------
# Cross target Component build specific configuration
#----------------------------------------------------
Expand Down Expand Up @@ -231,10 +227,6 @@ if(CLR_CMAKE_HOST_UNIX)
add_subdirectory(nativeresources)
endif(CLR_CMAKE_HOST_UNIX)

if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 10.0))
add_compile_options(-Wno-error=stringop-overflow=)
endif()

add_subdirectory(utilcode)
add_subdirectory(inc)

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ if(CLR_CMAKE_TARGET_WIN32)
get_include_directories(INC_DIR)
get_compile_definitions(PREPROCESS_DEFINITIONS)
list(APPEND INC_DIR -I${CLR_DIR}/vm -I${CLR_DIR}/vm/${ARCH_SOURCES_DIR} -I${CLR_DIR}/debug/ee -I${CLR_DIR}/gc)
list(APPEND PREPROCESS_DEFINITIONS -DDACCESS_COMPILE -DTARGET_64BIT)
list(APPEND PREPROCESS_DEFINITIONS -DDACCESS_COMPILE)

if (CLR_CMAKE_HOST_ARCH_AMD64)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_AMD64)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/hosts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ include_directories(inc)

if(CLR_CMAKE_HOST_WIN32)
add_subdirectory(coreshim)
else(CLR_CMAKE_HOST_WIN32)
add_definitions(-D_FILE_OFFSET_BITS=64)
endif(CLR_CMAKE_HOST_WIN32)

add_subdirectory(corerun)
1 change: 0 additions & 1 deletion src/coreclr/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ endif(FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION)
add_definitions(-DLP64COMPATIBLE)
add_definitions(-DCORECLR)
add_definitions(-DPIC)
add_definitions(-D_FILE_OFFSET_BITS=64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@am11 why have you removed this line and the same one in the configure.cmake and inb the hosts CMakeLists? It is not correct, we want to support 64 bit file offsets on all platforms. The PAL tests on ARM are now failing due to this (see #58481). I don't see this removal mentioned in the PR description. I have not noticed this before, I was OOF when this PR was created and merged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janvorli, it was moved at common place:

# Unconditionally define _FILE_OFFSET_BITS as 64 on all platforms.
add_definitions(-D_FILE_OFFSET_BITS=64)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that doesn't influence the compiler options in the configure.cmake. So while this place and the hosts are likely ok, the configure.cmake change causes the problem, as we detect off_t as 4 bytes due to the missing define.

Copy link
Member Author

@am11 am11 Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can double-check, but I am pretty sure global defines are used in cmake introspection unless explicitly stripped off.

Besides, #58481 was opened ~11 hours before this PR was merged..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I mixed up; was checking on mobile, but it does seem like first occurrence of File sizes do not match up. happened after this was merged. The one on 24th of August is different error Call to SetEndOfFile failed with 112. Will check it out shortly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just verified that adding that line back to configure.cmake fixes the failing tests (I've tried without it to eliminate the possibility that something else is in play here). And the global defines are really not used in the introspection, I've checked the CMakeOutput.txt and the only definitions passed to the compiler were the ones in the CMAKE_REQUIRED_DEFINITIONS:

Run Build Command(s):/usr/bin/make cmTC_087a6/fast && /usr/bin/make -f CMakeFiles/cmTC_087a6.dir/build.make CMakeFiles/cmTC_087a6.dir/build
make[1]: Entering directory '/home/janvorli/git/runtime/artifacts/obj/coreclr/Linux.arm.Debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_087a6.dir/SIZEOF_OFF_T.c.o
/usr/bin/clang-9 -fPIE   -D_BSD_SOURCE -D_SVID_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -o CMakeFiles/cmTC_087a6.dir/SIZEOF_OFF_T.c.o   -c /home/janvorli/git/runtime/artifacts/obj/coreclr/Linux.arm.Debug/CMakeFiles/CheckTypeSize/SIZEOF_OFF_T.c
Linking C executable cmTC_087a6
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_087a6.dir/link.txt --verbose=1
/usr/bin/clang-9     -pie -Wl,--build-id=sha1 -Wl,-z,relro,-z,now  CMakeFiles/cmTC_087a6.dir/SIZEOF_OFF_T.c.o  -o cmTC_087a6
make[1]: Leaving directory '/home/janvorli/git/runtime/artifacts/obj/coreclr/Linux.arm.Debug/CMakeFiles/CMakeTmp'

Copy link
Member Author

@am11 am11 Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, we set CMAKE_REQUIRED_DEFINITIONS so whatever it had before is reset. #59504 for the fix. Thanks for spotting it! :)


if(CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_HOST_ALPINE_LINUX)
# Currently the _xstate is not available on Alpine Linux
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ else()
set(CMAKE_RT_LIBS "")
endif()

list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64)

check_include_files(ieeefp.h HAVE_IEEEFP_H)
check_include_files(sys/vmparam.h HAVE_SYS_VMPARAM_H)
check_include_files(mach/vm_types.h HAVE_MACH_VM_TYPES_H)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/encee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ HRESULT EditAndContinueModule::ResumeInUpdatedFunction(
if( newFrameSize > oldFrameSize)
{
DWORD frameIncrement = newFrameSize - oldFrameSize;
(void)alloca(frameIncrement);
(void)!alloca(frameIncrement);
am11 marked this conversation as resolved.
Show resolved Hide resolved
}

// Ask the EECodeManager to actually fill in the context and stack for the new frame so that
Expand Down
Loading