Skip to content

Commit dde7b22

Browse files
committed
Try and get CI to pass again
1 parent c39b1ae commit dde7b22

File tree

5 files changed

+111
-80
lines changed

5 files changed

+111
-80
lines changed

libc/CMakeLists.txt

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
3434
add_definitions("-D_DEBUG")
3535
endif()
3636

37-
3837
# Default to C++17
3938
set(CMAKE_CXX_STANDARD 17)
4039

@@ -131,13 +130,6 @@ endif()
131130

132131
# Defines LIBC_TARGET_ARCHITECTURE and associated macros.
133132
set(LIBC_TARGET_TRIPLE "" CACHE STRING "The target triple for the libc build.")
134-
include(LLVMLibCArchitectures)
135-
136-
# Some targets can only support the full build.
137-
set(default_to_full_build OFF)
138-
if(LIBC_TARGET_OS_IS_GPU)
139-
set(default_to_full_build ON)
140-
endif()
141133

142134
option(LLVM_LIBC_FULL_BUILD "Build and test LLVM libc as if it is the full libc" ${default_to_full_build})
143135
option(LLVM_LIBC_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR "Build LLVM libc tests assuming our implementation-defined behavior" ON)
@@ -151,24 +143,6 @@ set(LIBC_ENABLE_HERMETIC_TESTS ${LLVM_LIBC_FULL_BUILD})
151143

152144
set(LIBC_CONFIG_JSON_FILE_LIST "")
153145

154-
if(NOT LIBC_CONFIG_PATH)
155-
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
156-
if(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
157-
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
158-
set(LIBC_CONFIG_PATH "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
159-
elseif(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
160-
set(LIBC_CONFIG_PATH "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
161-
endif()
162-
else()
163-
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_CONFIG_PATH}")
164-
endif()
165-
166-
if(NOT LIBC_CONFIG_PATH)
167-
message(FATAL_ERROR "Configs for the platform '${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}' do not exist and LIBC_CONFIG_PATH is not set.")
168-
elseif(LIBC_CMAKE_VERBOSE_LOGGING)
169-
message(STATUS "Path for config files is: ${LIBC_CONFIG_PATH}")
170-
endif()
171-
172146
# option(LIBC_ENABLE_WIDE_CHARACTERS
173147
# "Whether to enable wide character functions on supported platforms. This may
174148
# also set flags to enable or disable wide character support within other
@@ -177,51 +151,6 @@ endif()
177151
#TODO: Add carve-out specific config files to the list here.
178152

179153
include(LibcConfig)
180-
# Config loading happens in three steps:
181-
# 1. Load the config file config/config.json and set up config vars.
182-
# 2. Load config/${LIBC_TARGET_OS}/config.json if available and override
183-
# vars as suitable.
184-
# 3. Load config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCH}/config.json is
185-
# available and override vars as suitable.
186-
# All the three steps will not override options already set from the
187-
# CMake command line. That is, the CMake command line option values take
188-
# precedence over the values in config.json files.
189-
set(main_config_file ${LIBC_SOURCE_DIR}/config/config.json)
190-
read_libc_config(${main_config_file} global_config)
191-
foreach(opt IN LISTS global_config)
192-
string(JSON opt_name ERROR_VARIABLE json_error MEMBER ${opt} 0)
193-
if(json_error)
194-
message(FATAL_ERROR ${json_error})
195-
endif()
196-
if(DEFINED ${opt_name})
197-
# The option is already defined from the command line so we ignore it here.
198-
# We still make note of it so that further config load can also ignore
199-
# this option.
200-
message(STATUS "${opt_name}: ${${opt_name}} (from command line)")
201-
list(APPEND cmd_line_conf ${opt_name})
202-
continue()
203-
endif()
204-
205-
string(JSON opt_object ERROR_VARIABLE json_error GET ${opt} ${opt_name})
206-
if(json_error)
207-
message(FATAL_ERROR "Error reading info of option '${opt_name}': ${json_error}")
208-
endif()
209-
string(JSON opt_value ERROR_VARIABLE json_error GET ${opt_object} "value")
210-
if(json_error)
211-
message(FATAL_ERROR ${json_error})
212-
endif()
213-
message(STATUS "${opt_name}: ${opt_value}")
214-
set(${opt_name} ${opt_value})
215-
endforeach()
216-
generate_config_doc(${main_config_file} ${LIBC_SOURCE_DIR}/docs/configure.rst)
217-
218-
# Load each target specific config.
219-
foreach(config_path IN LISTS LIBC_CONFIG_JSON_FILE_LIST)
220-
if(LIBC_CMAKE_VERBOSE_LOGGING)
221-
message(STATUS "Loading additional config: '${config_path}/config.json'")
222-
endif()
223-
load_libc_config(${config_path}/config.json ${cmd_line_conf})
224-
endforeach()
225154

226155
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
227156
set(LIBC_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})

libc/cmake/modules/LibcConfig.cmake

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ endfunction()
106106
# argument. Typically, these will be the options specified on the CMake
107107
# command line.
108108
function(load_libc_config config_file)
109+
set(changed_vars "")
109110
read_libc_config(${config_file} file_opts)
110111
foreach(opt IN LISTS file_opts)
111112
string(JSON opt_name ERROR_VARIABLE json_error MEMBER ${opt} 0)
@@ -132,7 +133,9 @@ function(load_libc_config config_file)
132133
endif()
133134
message(STATUS "Overriding - ${opt_name}: ${opt_value} (Previous value: ${${opt_name}})")
134135
set(${opt_name} ${opt_value} PARENT_SCOPE)
136+
list(APPEND changed_vars ${opt_name})
135137
endforeach()
138+
set(changed_vars "${changed_vars}" PARENT_SCOPE)
136139
endfunction()
137140

138141
function(generate_config_doc config_file doc_file)
@@ -215,3 +218,103 @@ function(generate_config_doc config_file doc_file)
215218
message(STATUS "Writing config doc to ${doc_file}")
216219
file(WRITE ${doc_file} ${doc_string})
217220
endfunction()
221+
222+
#--------------------------
223+
# Entry point (shared between libc/libcxx)
224+
#--------------------------
225+
226+
if(NOT DEFINED LIBC_SOURCE_DIR)
227+
set(LIBC_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
228+
message(WARNING "LIBC_SOURCE_DIR: ${LIBC_SOURCE_DIR}")
229+
endif()
230+
231+
include(LLVMLibCArchitectures)
232+
233+
# Some targets can only support the full build.
234+
set(default_to_full_build OFF)
235+
if(LIBC_TARGET_OS_IS_GPU)
236+
set(default_to_full_build ON)
237+
endif()
238+
239+
if(NOT LIBC_CONFIG_PATH)
240+
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
241+
if(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
242+
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
243+
set(LIBC_CONFIG_PATH "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
244+
elseif(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
245+
set(LIBC_CONFIG_PATH "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
246+
endif()
247+
else()
248+
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_CONFIG_PATH}")
249+
endif()
250+
251+
if(NOT LIBC_CONFIG_PATH)
252+
message(FATAL_ERROR "Configs for the platform '${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}' do not exist and LIBC_CONFIG_PATH is not set.")
253+
elseif(LIBC_CMAKE_VERBOSE_LOGGING)
254+
message(STATUS "Path for config files is: ${LIBC_CONFIG_PATH}")
255+
endif()
256+
257+
# Config loading happens in three steps:
258+
# 1. Load the config file config/config.json and set up config vars.
259+
# 2. Load config/${LIBC_TARGET_OS}/config.json if available and override
260+
# vars as suitable.
261+
# 3. Load config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCH}/config.json is
262+
# available and override vars as suitable.
263+
# All the three steps will not override options already set from the
264+
# CMake command line. That is, the CMake command line option values take
265+
# precedence over the values in config.json files.
266+
set(main_config_file ${LIBC_SOURCE_DIR}/config/config.json)
267+
read_libc_config(${main_config_file} global_config)
268+
foreach(opt IN LISTS global_config)
269+
string(JSON opt_name ERROR_VARIABLE json_error MEMBER ${opt} 0)
270+
if(json_error)
271+
message(FATAL_ERROR ${json_error})
272+
endif()
273+
if(DEFINED ${opt_name})
274+
# The option is already defined from the command line so we ignore it here.
275+
# We still make note of it so that further config load can also ignore
276+
# this option.
277+
message(STATUS "${opt_name}: ${${opt_name}} (from command line)")
278+
list(APPEND cmd_line_conf ${opt_name})
279+
continue()
280+
endif()
281+
282+
string(JSON opt_object ERROR_VARIABLE json_error GET ${opt} ${opt_name})
283+
if(json_error)
284+
message(FATAL_ERROR "Error reading info of option '${opt_name}': ${json_error}")
285+
endif()
286+
string(JSON opt_value ERROR_VARIABLE json_error GET ${opt_object} "value")
287+
if(json_error)
288+
message(FATAL_ERROR ${json_error})
289+
endif()
290+
message(STATUS "${opt_name}: ${opt_value}")
291+
set(${opt_name} ${opt_value})
292+
set(${opt_name} ${opt_value} PARENT_SCOPE)
293+
endforeach()
294+
generate_config_doc(${main_config_file} ${LIBC_SOURCE_DIR}/docs/configure.rst)
295+
296+
message(WARNING "LIBC_SOURCE_DIR: ${LIBC_SOURCE_DIR}")
297+
message(WARNING "LIBC_CONFIG_PATH: ${LIBC_CONFIG_PATH}")
298+
if(NOT LIBC_CONFIG_PATH)
299+
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
300+
if(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
301+
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
302+
set(LIBC_CONFIG_PATH "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}")
303+
elseif(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
304+
set(LIBC_CONFIG_PATH "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}")
305+
endif()
306+
else()
307+
list(APPEND LIBC_CONFIG_JSON_FILE_LIST "${LIBC_CONFIG_PATH}")
308+
endif()
309+
310+
# Load each target specific config.
311+
foreach(config_path IN LISTS LIBC_CONFIG_JSON_FILE_LIST)
312+
if(LIBC_CMAKE_VERBOSE_LOGGING)
313+
message(STATUS "Loading additional config: '${config_path}/config.json'")
314+
endif()
315+
load_libc_config(${config_path}/config.json ${cmd_line_conf})
316+
# Proprogate changed_vars
317+
foreach(var IN LISTS changed_vars)
318+
set(${var} "${${var}}" PARENT_SCOPE)
319+
endforeach()
320+
endforeach()

libc/shared/libc_common.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
#ifndef LLVM_LIBC_SHARED_LIBC_COMMON_H
1010
#define LLVM_LIBC_SHARED_LIBC_COMMON_H
1111

12+
#include "src/__support/libc_errno.h" // LIBC_ERRNO_MODE_*
13+
#include "src/__support/threads/mutex.h" // LIBC_THREAD_MODE_*
14+
1215
// Use system errno.
1316
#ifdef LIBC_ERRNO_MODE
14-
#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM_INLINE
15-
#error \
16-
"LIBC_ERRNO_MODE was set to something different from LIBC_ERRNO_MODE_SYSTEM_INLINE."
17-
#endif // LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM_INLINE
18-
#else
17+
#undef LIBC_ERRNO_MODE
1918
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM_INLINE
2019
#endif // LIBC_ERRNO_MODE
2120

libc/src/__support/macros/attributes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define LIBC_INLINE_ASM __asm__ __volatile__
2929
#define LIBC_UNUSED __attribute__((unused))
3030

31-
#ifdef LIBC_TARGET_ARCH_IS_GPU
31+
#if LIBC_THREAD_MODE == LIBC_THREAD_MODE_SINGLE
3232
#define LIBC_THREAD_LOCAL
3333
#else
3434
#define LIBC_THREAD_LOCAL thread_local

libc/src/__support/threads/mutex.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_MUTEX_H
1010
#define LLVM_LIBC_SRC___SUPPORT_THREADS_MUTEX_H
1111

12-
#include "src/__support/macros/attributes.h"
13-
#include "src/__support/macros/config.h"
14-
1512
// Uses the platform specific specialization
1613
#define LIBC_THREAD_MODE_PLATFORM 0
1714

@@ -34,6 +31,9 @@ LIBC_THREAD_MODE_SINGLE, \
3431
LIBC_THREAD_MODE_EXTERNAL.
3532
#endif
3633

34+
#include "src/__support/macros/attributes.h"
35+
#include "src/__support/macros/config.h"
36+
3737
#if LIBC_THREAD_MODE == LIBC_THREAD_MODE_PLATFORM
3838

3939
// Platform independent code will include this header file which pulls

0 commit comments

Comments
 (0)