Skip to content

Commit aeccc16

Browse files
committed
Re-land [libc] Apply no-builtin everywhere, remove unnecessary flags
This is a reland of D126773 / b2a9ea4. The removal of `-mllvm -combiner-global-alias-analysis` has landed separately in D128051 / 7b73f53. And the removal of `-mllvm --tail-merge-threshold=0` is scheduled for removal in a subsequent patch.
1 parent 60a3215 commit aeccc16

File tree

4 files changed

+4
-36
lines changed

4 files changed

+4
-36
lines changed

libc/cmake/modules/LLVMLibCObjectRules.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function(_get_common_compile_options output_var flags)
1111

1212
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN})
1313
if(NOT ${LIBC_TARGET_OS} STREQUAL "windows")
14-
set(compile_options ${compile_options} -fpie -ffreestanding)
14+
set(compile_options ${compile_options} -fpie -ffreestanding -fno-builtin)
1515
endif()
1616
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
1717
list(APPEND compile_options "-fno-exceptions")

libc/src/string/CMakeLists.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ function(add_bcmp bcmp_name)
308308
DEPENDS
309309
.memory_utils.memory_utils
310310
libc.include.string
311-
COMPILE_OPTIONS
312-
-fno-builtin-memcmp
313-
-fno-builtin-bcmp
314311
${ARGN}
315312
)
316313
endfunction()
@@ -338,8 +335,6 @@ function(add_bzero bzero_name)
338335
DEPENDS
339336
.memory_utils.memset_implementation
340337
libc.include.string
341-
COMPILE_OPTIONS
342-
-fno-builtin-bzero
343338
${ARGN}
344339
)
345340
endfunction()
@@ -367,8 +362,6 @@ function(add_memcmp memcmp_name)
367362
DEPENDS
368363
.memory_utils.memcmp_implementation
369364
libc.include.string
370-
COMPILE_OPTIONS
371-
-fno-builtin-memcmp
372365
${ARGN}
373366
)
374367
endfunction()
@@ -399,8 +392,6 @@ function(add_memcpy memcpy_name)
399392
DEPENDS
400393
.memory_utils.memcpy_implementation
401394
libc.include.string
402-
COMPILE_OPTIONS
403-
-fno-builtin-memcpy
404395
${ARGN}
405396
)
406397
endfunction()
@@ -433,8 +424,6 @@ function(add_memmove memmove_name)
433424
DEPENDS
434425
.memory_utils.memory_utils
435426
libc.include.string
436-
COMPILE_OPTIONS
437-
-fno-builtin
438427
${ARGN}
439428
)
440429
endfunction()
@@ -467,8 +456,6 @@ function(add_memset memset_name)
467456
DEPENDS
468457
.memory_utils.memset_implementation
469458
libc.include.string
470-
COMPILE_OPTIONS
471-
-fno-builtin-memset
472459
${ARGN}
473460
)
474461
endfunction()

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ load("@bazel_skylib//lib:selects.bzl", "selects")
99

1010
package(
1111
default_visibility = ["//visibility:public"],
12+
features = ["-use_header_modules"],
1213
licenses = ["notice"],
1314
)
1415

@@ -826,11 +827,7 @@ libc_function(
826827
name = "memcpy",
827828
srcs = ["src/string/memcpy.cpp"],
828829
hdrs = ["src/string/memcpy.h"],
829-
copts = [
830-
"-fno-builtin-memcpy",
831-
"-fno-builtin-memmove",
832-
"-mllvm --tail-merge-threshold=0",
833-
],
830+
copts = ["-mllvm --tail-merge-threshold=0"],
834831
features = no_sanitize_features,
835832
deps = [
836833
":__support_common",
@@ -842,9 +839,6 @@ libc_function(
842839
name = "memset",
843840
srcs = ["src/string/memset.cpp"],
844841
hdrs = ["src/string/memset.h"],
845-
copts = [
846-
"-fno-builtin-memset",
847-
],
848842
features = no_sanitize_features,
849843
deps = [
850844
":__support_common",
@@ -856,9 +850,6 @@ libc_function(
856850
name = "memmove",
857851
srcs = ["src/string/memmove.cpp"],
858852
hdrs = ["src/string/memmove.h"],
859-
copts = [
860-
"-fno-builtin-memmove",
861-
],
862853
features = no_sanitize_features,
863854
deps = [
864855
":__support_common",
@@ -871,9 +862,6 @@ libc_function(
871862
name = "memcmp",
872863
srcs = ["src/string/memcmp.cpp"],
873864
hdrs = ["src/string/memcmp.h"],
874-
copts = [
875-
"-fno-builtin-memcmp",
876-
],
877865
features = no_sanitize_features,
878866
deps = [
879867
":__support_common",
@@ -886,10 +874,6 @@ libc_function(
886874
name = "bcmp",
887875
srcs = ["src/string/bcmp.cpp"],
888876
hdrs = ["src/string/bcmp.h"],
889-
copts = [
890-
"-fno-builtin-bcmp",
891-
"-fno-builtin-memcmp",
892-
],
893877
features = no_sanitize_features,
894878
deps = [
895879
":__support_common",
@@ -901,10 +885,6 @@ libc_function(
901885
name = "bzero",
902886
srcs = ["src/string/bzero.cpp"],
903887
hdrs = ["src/string/bzero.h"],
904-
copts = [
905-
"-fno-builtin-bzero",
906-
"-fno-builtin-memset",
907-
],
908888
features = no_sanitize_features,
909889
deps = [
910890
":__support_common",

utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def libc_function(name, srcs, deps = None, copts = None, **kwargs):
3131
deps.append(LIBC_ROOT_TARGET)
3232
copts = copts or []
3333
copts.append("-O3")
34+
copts.append("-fno-builtin")
3435

3536
# We compile the code twice, the first target is suffixed with ".__internal__" and contains the
3637
# C++ functions in the "__llvm_libc" namespace. This allows us to test the function in the

0 commit comments

Comments
 (0)