-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc][libcxx] Support for building libc++ against LLVM libc #99287
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
Changes from 2 commits
7d7a788
76e5e02
c6ca8cf
1418ea8
a27eaa4
1777997
9f90269
0cafc79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,6 +226,15 @@ set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros | |
set(LIBCXX_EXTRA_SITE_DEFINES "" CACHE STRING "Extra defines to add into __config_site") | ||
option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) | ||
|
||
# C Library options ----------------------------------------------------------- | ||
|
||
set(LIBCXX_DEFAULT_C_LIBRARY system) | ||
set(LIBCXX_SUPPORTED_C_LIBRARIES system llvm-libc) | ||
set(LIBCXX_LIBC "${LIBCXX_DEFAULT_C_LIBRARY}" CACHE STRING "Specify C library to use. Supported values are ${LIBCXX_SUPPORTED_C_LIBRARIES}.") | ||
if (NOT "${LIBCXX_LIBC}" IN_LIST LIBCXX_SUPPORTED_C_LIBRARIES) | ||
message(FATAL_ERROR "Unsupported C library: '${LIBCXX_CXX_ABI}'. Supported values are ${LIBCXX_SUPPORTED_C_LIBRARIES}.") | ||
endif() | ||
|
||
# ABI Library options --------------------------------------------------------- | ||
if (MSVC) | ||
set(LIBCXX_DEFAULT_ABI_LIBRARY "vcruntime") | ||
|
@@ -509,6 +518,7 @@ endif() | |
# Setup Compiler Flags | ||
#=============================================================================== | ||
|
||
include(HandleLibC) # Setup the C library flags | ||
include(HandleLibCXXABI) # Setup the ABI library flags | ||
|
||
# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. | ||
|
@@ -784,6 +794,10 @@ config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTER | |
config_define_if_not(LIBCXX_ENABLE_TIME_ZONE_DATABASE _LIBCPP_HAS_NO_TIME_ZONE_DATABASE) | ||
config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | ||
|
||
if (LIBCXX_LIBC STREQUAL "llvm-libc") | ||
config_define(ON _LIBCPP_HAS_LLVM_LIBC) | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not going to block this patch on fixing this, but we don't want to add a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed these and will address it more correctly in a follow up PR. |
||
|
||
if (LIBCXX_ENABLE_ASSERTIONS) | ||
message(DEPRECATION "LIBCXX_ENABLE_ASSERTIONS is deprecated and will be removed in LLVM 20. Please use LIBCXX_HARDENING_MODE instead.") | ||
set(LIBCXX_HARDENING_MODE "extensive") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#=============================================================================== | ||
# Define targets for linking against the selected C library | ||
# | ||
# After including this file, the following targets are defined: | ||
# - libcxx-libc-headers: An interface target that allows getting access to the | ||
# headers of the selected C library. | ||
# - libcxx-libc-shared: A target representing the selected shared C library. | ||
# - libcxx-libm-shared: A target representing the selected shared C math library. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not possible to roll this up into the libc target? From the libc++ side, we'd like to have the illusion that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
# - libcxx-libc-static: A target representing the selected static C library. | ||
# - libcxx-libm-static: A target representing the selected static C math library. | ||
#=============================================================================== | ||
|
||
# Link against a system-provided libc | ||
if (LIBCXX_LIBC STREQUAL "system") | ||
add_library(libcxx-libc-headers INTERFACE) | ||
|
||
add_library(libcxx-libc-static INTERFACE) | ||
add_library(libcxx-libm-static INTERFACE) | ||
|
||
add_library(libcxx-libc-shared INTERFACE) | ||
add_library(libcxx-libm-shared INTERFACE) | ||
|
||
# Link against the in-tree LLVM libc | ||
elseif (LIBCXX_LIBC STREQUAL "llvm-libc") | ||
add_library(libcxx-libc-headers INTERFACE) | ||
target_link_libraries(libcxx-libc-headers INTERFACE libc-headers) | ||
ldionne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
add_library(libcxx-libc-static ALIAS libc) | ||
add_library(libcxx-libm-static ALIAS libm) | ||
|
||
# TODO: There's no support for building LLVM libc as a shared library yet. | ||
add_library(libcxx-libc-shared INTERFACE) | ||
add_library(libcxx-libm-shared INTERFACE) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// -*- 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 _LIBCPP___LOCALE_LOCALE_BASE_API_LLVM_LIBC_H | ||
#define _LIBCPP___LOCALE_LOCALE_BASE_API_LLVM_LIBC_H | ||
|
||
#include <__support/xlocale/__nop_locale_mgmt.h> | ||
#include <__support/xlocale/__strtonum_fallback.h> | ||
#include <cstdlib> | ||
|
||
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_LLVM_LIBC_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.