Skip to content

Commit 98ba65d

Browse files
nickdesaulnierssmallp-o-p
authored and
smallp-o-p
committed
[libc][cmake] make i386 distinct from x86_64 (llvm#114477)
Configured via: $ cmake ../runtimes -G Ninja -DLLVM_ENABLE_LLD=ON \ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libc" \ -DLIBC_TARGET_TRIPLE=i386-linux-gnu -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ Link: llvm#93709
1 parent bf11dab commit 98ba65d

File tree

9 files changed

+39
-10
lines changed

9 files changed

+39
-10
lines changed

libc/cmake/modules/LLVMLibCArchitectures.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
3939
set(target_arch "arm")
4040
elseif(target_arch MATCHES "^aarch64")
4141
set(target_arch "aarch64")
42-
elseif(target_arch MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
42+
elseif(target_arch MATCHES "(x86_64)|(AMD64|amd64)")
4343
set(target_arch "x86_64")
44+
elseif(target_arch MATCHES "(^i.86$)")
45+
set(target_arch "i386")
4446
elseif(target_arch MATCHES "^(powerpc|ppc)")
4547
set(target_arch "power")
4648
elseif(target_arch MATCHES "^riscv32")
@@ -147,6 +149,8 @@ if(LIBC_TARGET_ARCHITECTURE STREQUAL "arm")
147149
elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "aarch64")
148150
set(LIBC_TARGET_ARCHITECTURE_IS_AARCH64 TRUE)
149151
elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "x86_64")
152+
set(LIBC_TARGET_ARCHITECTURE_IS_X86_64 TRUE)
153+
elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "i386")
150154
set(LIBC_TARGET_ARCHITECTURE_IS_X86 TRUE)
151155
elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "riscv64")
152156
set(LIBC_TARGET_ARCHITECTURE_IS_RISCV64 TRUE)

libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# Initialize ALL_CPU_FEATURES as empty list.
66
set(ALL_CPU_FEATURES "")
77

8-
if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
8+
if(LIBC_TARGET_ARCHITECTURE_IS_X86_64)
99
set(ALL_CPU_FEATURES SSE2 SSE4_2 AVX AVX2 AVX512F AVX512BW FMA)
1010
set(LIBC_COMPILE_OPTIONS_NATIVE -march=native)
11-
elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
11+
elseif(LIBC_TARGET_ARCHITECTURE_IS_AARCH64)
1212
set(ALL_CPU_FEATURES "FullFP16")
1313
set(LIBC_COMPILE_OPTIONS_NATIVE -mcpu=native)
1414
endif()

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ function(_get_compile_options_from_flags output_var)
1010

1111
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
1212
if(ADD_FMA_FLAG)
13-
if(LIBC_TARGET_ARCHITECTURE_IS_X86)
13+
if(LIBC_TARGET_ARCHITECTURE_IS_X86_64)
1414
list(APPEND compile_options "-mavx2")
1515
list(APPEND compile_options "-mfma")
1616
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
1717
list(APPEND compile_options "-D__LIBC_RISCV_USE_FMA")
1818
endif()
1919
endif()
2020
if(ADD_ROUND_OPT_FLAG)
21-
if(LIBC_TARGET_ARCHITECTURE_IS_X86)
21+
if(LIBC_TARGET_ARCHITECTURE_IS_X86_64)
2222
# ROUND_OPT_FLAG is only enabled if SSE4.2 is detected, not just SSE4.1,
2323
# because there was code to check for SSE4.2 already, and few CPUs only
2424
# have SSE4.1.
@@ -145,7 +145,7 @@ function(_get_common_compile_options output_var flags)
145145
endif()
146146
if (LIBC_CONF_KEEP_FRAME_POINTER)
147147
list(APPEND compile_options "-fno-omit-frame-pointer")
148-
if (LIBC_TARGET_ARCHITECTURE_IS_X86)
148+
if (LIBC_TARGET_ARCHITECTURE_IS_X86_64)
149149
list(APPEND compile_options "-mno-omit-leaf-frame-pointer")
150150
endif()
151151
endif()

libc/cmake/modules/LLVMLibCFlagRules.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,21 +268,21 @@ set(EXPLICIT_SIMD_OPT_FLAG "EXPLICIT_SIMD_OPT")
268268
set(MISC_MATH_BASIC_OPS_OPT_FLAG "MISC_MATH_BASIC_OPS_OPT")
269269

270270
# Skip FMA_OPT flag for targets that don't support fma.
271-
if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86 AND (LIBC_CPU_FEATURES MATCHES "FMA")) OR
271+
if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86_64 AND (LIBC_CPU_FEATURES MATCHES "FMA")) OR
272272
LIBC_TARGET_ARCHITECTURE_IS_RISCV64))
273273
set(SKIP_FLAG_EXPANSION_FMA_OPT TRUE)
274274
endif()
275275

276276
# Skip EXPLICIT_SIMD_OPT flag for targets that don't support SSE2.
277277
# Note: one may want to revisit it if they want to control other explicit SIMD
278-
if(NOT(LIBC_TARGET_ARCHITECTURE_IS_X86 AND (LIBC_CPU_FEATURES MATCHES "SSE2")))
278+
if(NOT(LIBC_TARGET_ARCHITECTURE_IS_X86_64 AND (LIBC_CPU_FEATURES MATCHES "SSE2")))
279279
set(SKIP_FLAG_EXPANSION_EXPLICIT_SIMD_OPT TRUE)
280280
endif()
281281

282282
# Skip ROUND_OPT flag for targets that don't support rounding instructions. On
283283
# x86, these are SSE4.1 instructions, but we already had code to check for
284284
# SSE4.2 support.
285-
if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86 AND (LIBC_CPU_FEATURES MATCHES "SSE4_2")) OR
285+
if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86_64 AND (LIBC_CPU_FEATURES MATCHES "SSE4_2")) OR
286286
LIBC_TARGET_ARCHITECTURE_IS_AARCH64 OR LIBC_TARGET_OS_IS_GPU))
287287
set(SKIP_FLAG_EXPANSION_ROUND_OPT TRUE)
288288
endif()

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function(add_integration_test test_name)
402402
if(NOT INTEGRATION_TEST_SRCS)
403403
message(FATAL_ERROR "The SRCS list for add_integration_test is missing.")
404404
endif()
405-
if(NOT TARGET libc.startup.${LIBC_TARGET_OS}.crt1)
405+
if(NOT LLVM_LIBC_FULL_BUILD AND NOT TARGET libc.startup.${LIBC_TARGET_OS}.crt1)
406406
message(FATAL_ERROR "The 'crt1' target for the integration test is missing.")
407407
endif()
408408

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set(TARGET_LIBC_ENTRYPOINTS
2+
# errno.h entrypoints
3+
libc.src.errno.errno
4+
)
5+
6+
set(TARGET_LIBM_ENTRYPOINTS "")
7+
8+
set(TARGET_LLVMLIBC_ENTRYPOINTS
9+
${TARGET_LIBC_ENTRYPOINTS}
10+
${TARGET_LIBM_ENTRYPOINTS}
11+
)

libc/config/linux/i386/headers.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set(TARGET_PUBLIC_HEADERS
2+
libc.include.assert
3+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
add_header_library(
2+
linux_i386_util
3+
HDRS
4+
syscall.h
5+
)
6+
7+
add_header_library(
8+
vdso
9+
HDRS
10+
vdso.h
11+
)

libc/src/__support/OSUtil/linux/i386/vdso.h

Whitespace-only changes.

0 commit comments

Comments
 (0)