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

Clangtastic Voyage #20392

Merged
merged 2 commits into from Feb 12, 2018
Merged

Clangtastic Voyage #20392

merged 2 commits into from Feb 12, 2018

Conversation

adamemerson
Copy link
Contributor

Fix Clang builds.
(Including Clang builds under Linux using libstdc++.)

Using an explicit {} initializer. This unbreaks Clang.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
@gregsfortytwo
Copy link
Member

But why? Why is clang unhappy with the existing state of affairs, and why does this explicit empty initializer make it better?

@batrick batrick added the cephfs Ceph File System label Feb 9, 2018
@adamemerson
Copy link
Contributor Author

@gregsfortytwo As of 7e2f59a , inode_t is no longer a class, it's a template with a defaulted argument.

Pre-C++17, you'd have to write inode_t<> everywhere you were writing inode_t as a default. The class deduction rules now let you avoid that, it can assume a defaulted template argument from the default constructor.

HOWEVER, it looks like in this case Clang 5 is /slightly/ wrong, and it requires you specify an empty initializer to get the default constructor explicitly, whereas g++ correctly uses that with no initializer specified at all.

I think Clang 6 fixes it, but it's not stable yet.

CMakeLists.txt Outdated
@@ -594,6 +594,30 @@ include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)

find_package(Threads REQUIRED)

if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
Copy link
Contributor

Choose a reason for hiding this comment

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

@adamemerson thanks for getting this right. i am just curious why you choosed to check the output of c++ compiler instead of using _LIBCPP_VERSION and __GLIBCXX__ in the librarycheck.cc file?

Copy link
Contributor

@tchaikov tchaikov Feb 10, 2018

Choose a reason for hiding this comment

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

also, if we use the combination of gcc and libc++, shall we link against c++experimental as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tchaikov I think no?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mattbenjamin why? as i don't think stdc++fs should be linked if libc++ is used.

CMakeLists.txt Outdated
elseif(HUGE_COMPILE_OUTPUT MATCHES "\"-lc\\+\\+\"")
set(CLANG_CXXLIB "libc++")
message(STATUS "We are using libc++.")
elseif(HUGE_COMPILE_OUTPUT MATCHES "\"-lc\\+\\+\"")
Copy link
Contributor

Choose a reason for hiding this comment

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

this branch looks quite like the previous one.

CMakeLists.txt Outdated
)

if(HUGE_COMPILE_OUTPUT MATCHES "\"-lstdc\\+\\+\"")
set(CLANG_CXXLIB "libstdc++")
Copy link
Contributor

@tchaikov tchaikov Feb 9, 2018

Choose a reason for hiding this comment

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

if the answer of the previous question evaluates to "true". the variable name is sort of misleading. as it has clang in it. how about CXX_STDLIB?

@@ -508,10 +508,10 @@ add_executable(ceph_test_admin_socket_output
)
target_link_libraries(ceph_test_admin_socket_output
ceph-common)
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CLANG_CXXLIB STREQUAL "libstdc++")
Copy link
Contributor

@tchaikov tchaikov Feb 9, 2018

Choose a reason for hiding this comment

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

thanks. but ... i think the library to be linked just depends on the C++ library we are using, so we probably we need to put

if(CLANG_CXXLIB STREQUAL "libstdc++")
  # ...
elseif(CLANG_CXXLIB STREQUAL "libc++")
  # ...
endif()

instead. what do you think?

@mattbenjamin
Copy link
Contributor

@gregsfortytwo because builds w/the clang-5 that ships w/F27 stopped working :)

Test whether we're building with libstdc++ or libc++.

Use stdc++filesystem if the former and c++experimental if the later.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
@adamemerson
Copy link
Contributor Author

@tchaikov How's this?

@mattbenjamin
Copy link
Contributor

mattbenjamin commented Feb 10, 2018

@tchaikov sorry, I probably misunderstood you; I thought I was joking about linking w/-lc++experimental

@adamemerson
Copy link
Contributor Author

Jenkins, retest this please.

Copy link
Contributor

@wjwithagen wjwithagen left a comment

Choose a reason for hiding this comment

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

The commit assigning empty to foo and bar works under Clang/FreeBSD.
Don't really have any comments abotu the Cmake patch

@tchaikov tchaikov merged commit 87e3aa6 into ceph:master Feb 12, 2018
@adamemerson adamemerson deleted the wip-clangtastic-voyage branch June 17, 2020 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants