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

Error building debug-pal's ds-ipc-posix.c with older cmake #48764

Closed
omajid opened this issue Feb 25, 2021 · 13 comments · Fixed by #48809
Closed

Error building debug-pal's ds-ipc-posix.c with older cmake #48764

omajid opened this issue Feb 25, 2021 · 13 comments · Fixed by #48809
Labels
area-Diagnostics-coreclr source-build Issues relating to dotnet/source-build
Milestone

Comments

@omajid
Copy link
Member

omajid commented Feb 25, 2021

I am having trouble building dotnet/runtime master branch (8483e9edc809c6d9799600d062abca8ab6c61e46) using an older CMake (cmake version 3.6.2) on RHEL 7:

Building CXX object debug/debug-pal/CMakeFiles/debug-pal_obj.dir/runtime/src/native/eventpipe/ds-ipc-posix.c.o
cd runtime/artifacts/obj/coreclr/Linux.x64.Release/debug/debug-pal && clang++-10   -DDISABLE_CONTRACTS -DFEATURE_CORECLR -DFEATURE_PERFTRACING -DFEATURE_PERFTRACING_STANDALONE_PAL -DHOST_64BIT -DHOST_AMD64 -DHOST_UNIX -DNDEBUG -DPAL_IMPLEMENTATION -DPAL_STDCPP_COMPAT -DTARGET_64BIT -DTARGET_AMD64 -DTARGET_LINUX -DTARGET_UNIX -DURTBLDENV_FRIENDLY=Retail -D_POSIX_C_SOURCE=200809L -Iruntime/src/coreclr/debug/debug-pal/../inc -Iruntime/src/coreclr/debug/debug-pal/../../pal/inc -Iruntime/src/native/eventpipe  -O2 -DNDEBUG -fPIC   -O3 -g -Wall -Wno-null-conversion -fno-omit-frame-pointer -fms-extensions -fwrapv -fstack-protector-strong -Werror -Wno-unused-variable -Wno-unused-value -Wno-unused-function -Wno-tautological-compare -Wimplicit-fallthrough -Wno-invalid-offsetof -ferror-limit=4096 -Wno-unused-private-field -Wno-microsoft -Wno-constant-logical-operand -Wno-pragma-pack -Wno-unknown-warning-option -Wno-incompatible-ms-struct -fsigned-char -fvisibility=hidden -std=gnu++11 -o CMakeFiles/debug-pal_obj.dir/runtime/src/native/eventpipe/ds-ipc-posix.c.o -c runtime/src/native/eventpipe/ds-ipc-posix.c
clang-10: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]                                             
gmake[2]: Leaving directory `runtime/artifacts/obj/coreclr/Linux.x64.Release'  

The command line here does not use the -xc++ flag set here:

set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_DIR}/ds-ipc-posix.c")
set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)

This makes me suspect that this is being caused by an older version of CMake.

I am not seeing this error on any other platform, all of which have newer cmake versions.

Is there a workaround for this possible? Or is runtime implicitly requiring a newer version of cmake now?

cc @dleeapho @tmds

@dotnet-issue-labeler dotnet-issue-labeler bot added area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner labels Feb 25, 2021
@ghost
Copy link

ghost commented Feb 25, 2021

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

I am having trouble building dotnet/runtime master branch (8483e9edc809c6d9799600d062abca8ab6c61e46) using an older CMake (cmake version 3.6.2) on RHEL 7:

Building CXX object debug/debug-pal/CMakeFiles/debug-pal_obj.dir/runtime/src/native/eventpipe/ds-ipc-posix.c.o
cd runtime/artifacts/obj/coreclr/Linux.x64.Release/debug/debug-pal && clang++-10   -DDISABLE_CONTRACTS -DFEATURE_CORECLR -DFEATURE_PERFTRACING -DFEATURE_PERFTRACING_STANDALONE_PAL -DHOST_64BIT -DHOST_AMD64 -DHOST_UNIX -DNDEBUG -DPAL_IMPLEMENTATION -DPAL_STDCPP_COMPAT -DTARGET_64BIT -DTARGET_AMD64 -DTARGET_LINUX -DTARGET_UNIX -DURTBLDENV_FRIENDLY=Retail -D_POSIX_C_SOURCE=200809L -Iruntime/src/coreclr/debug/debug-pal/../inc -Iruntime/src/coreclr/debug/debug-pal/../../pal/inc -Iruntime/src/native/eventpipe  -O2 -DNDEBUG -fPIC   -O3 -g -Wall -Wno-null-conversion -fno-omit-frame-pointer -fms-extensions -fwrapv -fstack-protector-strong -Werror -Wno-unused-variable -Wno-unused-value -Wno-unused-function -Wno-tautological-compare -Wimplicit-fallthrough -Wno-invalid-offsetof -ferror-limit=4096 -Wno-unused-private-field -Wno-microsoft -Wno-constant-logical-operand -Wno-pragma-pack -Wno-unknown-warning-option -Wno-incompatible-ms-struct -fsigned-char -fvisibility=hidden -std=gnu++11 -o CMakeFiles/debug-pal_obj.dir/runtime/src/native/eventpipe/ds-ipc-posix.c.o -c runtime/src/native/eventpipe/ds-ipc-posix.c
clang-10: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]                                             
gmake[2]: Leaving directory `runtime/artifacts/obj/coreclr/Linux.x64.Release'  

The command line here does not use the -xc++ flag set here:

set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_DIR}/ds-ipc-posix.c")
set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)

This makes me suspect that this is being caused by an older version of CMake.

I am not seeing this error on any other platform, all of which have newer cmake versions.

Is there a workaround for this possible? Or is runtime implicitly requiring a newer version of cmake now?

cc @dleeapho @tmds

Author: omajid
Assignees: -
Labels:

area-Diagnostics-coreclr, untriaged

Milestone: -

@omajid
Copy link
Member Author

omajid commented Feb 25, 2021

Looking at my build history, this error seems to have started happening just after #47665 (at least the same day) was merged, which makes sense, because that's when ds-ipc-posix.c was added to the default build.

@omajid
Copy link
Member Author

omajid commented Feb 25, 2021

Disabling warnings makes the build work.

@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label Feb 26, 2021
@tommcdon tommcdon added this to the 6.0.0 milestone Feb 26, 2021
@tommcdon tommcdon added the source-build Issues relating to dotnet/source-build label Feb 26, 2021
@tommcdon
Copy link
Member

@lateralusX @josalem @hoyosjs

@hoyosjs
Copy link
Member

hoyosjs commented Feb 26, 2021

Yes, this is indeed an issue on the CMake file that were added as part of the shared EP. I believe the version of CMake used by source-build for RHEL can't use PROPERTIES COMPILE_OPTIONS afaik. You'd probably need to use

add_compile_options(-xc++)

@hoyosjs
Copy link
Member

hoyosjs commented Feb 26, 2021

I am also not 100% sure about PROPERTIES LANGUAGE CXX.

@lateralusX
Copy link
Member

lateralusX commented Feb 26, 2021

https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/linux-requirements.md#toolchain-setup, says we need CMake 3.14.5 or newer, but looks like we did a downgrade just for coreclr directory, #39044

PROPERTIES LANGUAGE CXX should be available since v3.0, https://cmake.org/cmake/help/v3.0/prop_sf/LANGUAGE.html
PROPERTIES COMPILE_OPTIONS CXX compile option was added in v3.11, https://cmake.org/cmake/help/v3.11/prop_sf/COMPILE_OPTIONS.html

@lateralusX
Copy link
Member

add_compile_options(-xc++) could probably be used on older cmake versions, but it will then be applied to potentially more sources then expected.

The same semantics is also used for EventPipe Sources

set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++)
, but doesn't seem you hit that issue, maybe you don't build with FEATURE_PERFTRACING ?

@lateralusX
Copy link
Member

Guess we potentially could add:

if (CMAKE_VERSION VERSION_GREATER 3.11 OR CMAKE_VERSION VERSION_EQUAL 3.11)
    set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) 
else(CMAKE_VERSION VERSION_GREATER 3.11 OR CMAKE_VERSION VERSION_EQUAL 3.11)
    add_compile_options(-xc++)
endif()

@lateralusX
Copy link
Member

lateralusX commented Feb 26, 2021

Will fix this, running a test with above fix on CMake 3.6.2 using our CentOS 7 (build for RHEL 7) docker image https://github.com/dotnet/runtime/blob/master/docs/workflow/building/coreclr/linux-instructions.md#docker-images, our docker images all run on later CMake versions though, so needed to make a manual downgrade to 3.6.2.

@lateralusX
Copy link
Member

Successfully build using that docker image and CMake 3.6.2.

@lateralusX
Copy link
Member

#48809

@omajid
Copy link
Member Author

omajid commented Mar 1, 2021

Thanks for fixing this so quickly!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Diagnostics-coreclr source-build Issues relating to dotnet/source-build
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants