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

[libc++] Build with -fsized-deallocation #96217

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Jun 20, 2024

This patch makes libc++ build with -fsized-deallocation. That flag is
enabled by default in recent versions of Clang, so this patch will make
libc++ forward-compatible with ToT Clang.

@ldionne ldionne requested a review from EricWF June 20, 2024 17:32
@ldionne ldionne requested review from a team as code owners June 20, 2024 17:32
@llvmbot llvmbot added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc++abi libc++abi C++ Runtime Library. Not libc++. labels Jun 20, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 20, 2024

@llvm/pr-subscribers-libcxxabi

Author: Louis Dionne (ldionne)

Changes

This patch makes libc++ and libc++abi build with -fsized-deallocation. That flag is enabled by default in recent versions of Clang, so this patch will make these runtimes forward-compatible with ToT Clang.


Full diff: https://github.com/llvm/llvm-project/pull/96217.diff

2 Files Affected:

  • (modified) libcxx/CMakeLists.txt (+4)
  • (modified) libcxxabi/CMakeLists.txt (+4)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 4b927017f8c2a..f0946b6022280 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -553,6 +553,10 @@ function(cxx_add_basic_build_flags target)
     target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden)
   endif()
 
+  # Build with -fsized-deallocation, which is default in recent versions of Clang.
+  # TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
+  target_compile_options(${target} PRIVATE -fsized-deallocation)
+
   # Let the library headers know they are currently being used to build the
   # library.
   target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY)
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 52ba52f3439fb..d45b104b41e32 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -247,6 +247,10 @@ endif()
 add_compile_flags("${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}")
 add_library_flags("${LIBCXXABI_ADDITIONAL_LIBRARIES}")
 
+# Build with -fsized-deallocation, which is default in recent versions of Clang.
+# TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
+add_compile_flags(-fsized-deallocation)
+
 # Configure compiler. Must happen after setting the target flags.
 include(config-ix)
 

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 20, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

This patch makes libc++ and libc++abi build with -fsized-deallocation. That flag is enabled by default in recent versions of Clang, so this patch will make these runtimes forward-compatible with ToT Clang.


Full diff: https://github.com/llvm/llvm-project/pull/96217.diff

2 Files Affected:

  • (modified) libcxx/CMakeLists.txt (+4)
  • (modified) libcxxabi/CMakeLists.txt (+4)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 4b927017f8c2a..f0946b6022280 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -553,6 +553,10 @@ function(cxx_add_basic_build_flags target)
     target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden)
   endif()
 
+  # Build with -fsized-deallocation, which is default in recent versions of Clang.
+  # TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
+  target_compile_options(${target} PRIVATE -fsized-deallocation)
+
   # Let the library headers know they are currently being used to build the
   # library.
   target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY)
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 52ba52f3439fb..d45b104b41e32 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -247,6 +247,10 @@ endif()
 add_compile_flags("${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}")
 add_library_flags("${LIBCXXABI_ADDITIONAL_LIBRARIES}")
 
+# Build with -fsized-deallocation, which is default in recent versions of Clang.
+# TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
+add_compile_flags(-fsized-deallocation)
+
 # Configure compiler. Must happen after setting the target flags.
 include(config-ix)
 

@@ -247,6 +247,10 @@ endif()
add_compile_flags("${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}")
add_library_flags("${LIBCXXABI_ADDITIONAL_LIBRARIES}")

# Build with -fsized-deallocation, which is default in recent versions of Clang.
# TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
add_compile_flags(-fsized-deallocation)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this change should affect anything. Can we drop it and see what happens?

The size-deallocation functions should always be present in the library, and we shouldn't be calling new/delete from inside the library (I think?)

Copy link
Member Author

Choose a reason for hiding this comment

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

The size-deallocation functions should always be present in the library,

I don't think that's true, libc++abi doesn't define operator new in all configurations. In some configurations it is provided by libc++ instead.

and we shouldn't be calling new/delete from inside the library (I think?)

However that should definitely be correct, so I think you're right I could drop that part of the change. I'll try that.

Copy link
Member

@EricWF EricWF left a comment

Choose a reason for hiding this comment

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

Lets see how the bots come back, they should break hopefully.

This patch makes libc++ build with -fsized-deallocation. That flag is
enabled by default in recent versions of Clang, so this patch will make
libc++ forward-compatible with ToT Clang.
@ldionne ldionne force-pushed the review/build-with-sized-deallocation branch from 77b9cce to ab0d435 Compare June 20, 2024 17:58
@ldionne ldionne changed the title [libc++][libc++abi] Build with -fsized-deallocation [libc++] Build with -fsized-deallocation Jun 20, 2024
@EricWF
Copy link
Member

EricWF commented Jun 20, 2024

Fascinating. It appears the readelf: Warning: Unrecognized form: 0x23 messages in the output are related to sized deallocation.

I assumed they were due to the upgrade, but it appears not.

Nevermind, the readelf messages are always present, I've just never noticed them.

@EricWF
Copy link
Member

EricWF commented Jun 20, 2024

Also maybe we should move the ABI checking to a single build configuration. Since most of the configurations build libc++ /libc++abi in the same way, they should all have the same results.

That way breakages like this are less disruptive?

@ldionne
Copy link
Member Author

ldionne commented Jun 24, 2024

Looks like the CI failures are Android via an out-of-memory issue (which looks like a flake), and the bootstrapping build failure that we need this patch in order to fix. Merging.

@ldionne ldionne merged commit d2864d1 into llvm:main Jun 24, 2024
54 of 57 checks passed
@ldionne ldionne deleted the review/build-with-sized-deallocation branch June 24, 2024 21:26
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
This patch makes libc++ build with -fsized-deallocation. That flag is
enabled by default in recent versions of Clang, so this patch will make
libc++ forward-compatible with ToT Clang.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++abi libc++abi C++ Runtime Library. Not libc++. libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants