[libc-commits] [libc] aeccc16 - Re-land [libc] Apply no-builtin everywhere, remove unnecessary flags

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Wed Jun 22 05:30:36 PDT 2022


Author: Guillaume Chatelet
Date: 2022-06-22T12:30:20Z
New Revision: aeccc16497a84d61200f7ccfa3864096349260d3

URL: https://github.com/llvm/llvm-project/commit/aeccc16497a84d61200f7ccfa3864096349260d3
DIFF: https://github.com/llvm/llvm-project/commit/aeccc16497a84d61200f7ccfa3864096349260d3.diff

LOG: Re-land [libc] Apply no-builtin everywhere, remove unnecessary flags

This is a reland of D126773 / b2a9ea4420127d10b18ae648b16757665f8bbd7c.

The removal of `-mllvm -combiner-global-alias-analysis` has landed separately
in D128051 / 7b73f53790f3db9ee589dc26a05a481a5e9e6915.

And the removal of `-mllvm --tail-merge-threshold=0` is scheduled for
removal in a subsequent patch.

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCObjectRules.cmake
    libc/src/string/CMakeLists.txt
    utils/bazel/llvm-project-overlay/libc/BUILD.bazel
    utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 80ca475617b8a..496c8ba97a930 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -11,7 +11,7 @@ function(_get_common_compile_options output_var flags)
 
   set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN})
   if(NOT ${LIBC_TARGET_OS} STREQUAL "windows")
-    set(compile_options ${compile_options} -fpie -ffreestanding)
+    set(compile_options ${compile_options} -fpie -ffreestanding -fno-builtin)
   endif()
   if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
     list(APPEND compile_options "-fno-exceptions")

diff  --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index a2d89ae48b97d..68962e21c15d1 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -308,9 +308,6 @@ function(add_bcmp bcmp_name)
     DEPENDS
       .memory_utils.memory_utils
       libc.include.string
-    COMPILE_OPTIONS
-      -fno-builtin-memcmp
-      -fno-builtin-bcmp
     ${ARGN}
   )
 endfunction()
@@ -338,8 +335,6 @@ function(add_bzero bzero_name)
     DEPENDS
       .memory_utils.memset_implementation
       libc.include.string
-    COMPILE_OPTIONS
-      -fno-builtin-bzero
     ${ARGN}
   )
 endfunction()
@@ -367,8 +362,6 @@ function(add_memcmp memcmp_name)
     DEPENDS
       .memory_utils.memcmp_implementation
       libc.include.string
-    COMPILE_OPTIONS
-      -fno-builtin-memcmp
     ${ARGN}
   )
 endfunction()
@@ -399,8 +392,6 @@ function(add_memcpy memcpy_name)
     DEPENDS
       .memory_utils.memcpy_implementation
       libc.include.string
-    COMPILE_OPTIONS
-      -fno-builtin-memcpy
     ${ARGN}
   )
 endfunction()
@@ -433,8 +424,6 @@ function(add_memmove memmove_name)
     DEPENDS
       .memory_utils.memory_utils
       libc.include.string
-    COMPILE_OPTIONS
-      -fno-builtin
     ${ARGN}
   )
 endfunction()
@@ -467,8 +456,6 @@ function(add_memset memset_name)
     DEPENDS
       .memory_utils.memset_implementation
       libc.include.string
-    COMPILE_OPTIONS
-      -fno-builtin-memset
     ${ARGN}
   )
 endfunction()

diff  --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a0d423a0d40fb..0509790069e7e 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -9,6 +9,7 @@ load("@bazel_skylib//lib:selects.bzl", "selects")
 
 package(
     default_visibility = ["//visibility:public"],
+    features = ["-use_header_modules"],
     licenses = ["notice"],
 )
 
@@ -826,11 +827,7 @@ libc_function(
     name = "memcpy",
     srcs = ["src/string/memcpy.cpp"],
     hdrs = ["src/string/memcpy.h"],
-    copts = [
-        "-fno-builtin-memcpy",
-        "-fno-builtin-memmove",
-        "-mllvm --tail-merge-threshold=0",
-    ],
+    copts = ["-mllvm --tail-merge-threshold=0"],
     features = no_sanitize_features,
     deps = [
         ":__support_common",
@@ -842,9 +839,6 @@ libc_function(
     name = "memset",
     srcs = ["src/string/memset.cpp"],
     hdrs = ["src/string/memset.h"],
-    copts = [
-        "-fno-builtin-memset",
-    ],
     features = no_sanitize_features,
     deps = [
         ":__support_common",
@@ -856,9 +850,6 @@ libc_function(
     name = "memmove",
     srcs = ["src/string/memmove.cpp"],
     hdrs = ["src/string/memmove.h"],
-    copts = [
-        "-fno-builtin-memmove",
-    ],
     features = no_sanitize_features,
     deps = [
         ":__support_common",
@@ -871,9 +862,6 @@ libc_function(
     name = "memcmp",
     srcs = ["src/string/memcmp.cpp"],
     hdrs = ["src/string/memcmp.h"],
-    copts = [
-        "-fno-builtin-memcmp",
-    ],
     features = no_sanitize_features,
     deps = [
         ":__support_common",
@@ -886,10 +874,6 @@ libc_function(
     name = "bcmp",
     srcs = ["src/string/bcmp.cpp"],
     hdrs = ["src/string/bcmp.h"],
-    copts = [
-        "-fno-builtin-bcmp",
-        "-fno-builtin-memcmp",
-    ],
     features = no_sanitize_features,
     deps = [
         ":__support_common",
@@ -901,10 +885,6 @@ libc_function(
     name = "bzero",
     srcs = ["src/string/bzero.cpp"],
     hdrs = ["src/string/bzero.h"],
-    copts = [
-        "-fno-builtin-bzero",
-        "-fno-builtin-memset",
-    ],
     features = no_sanitize_features,
     deps = [
         ":__support_common",

diff  --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
index 85eb35cbdd99a..2e1732e499445 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -31,6 +31,7 @@ def libc_function(name, srcs, deps = None, copts = None, **kwargs):
     deps.append(LIBC_ROOT_TARGET)
     copts = copts or []
     copts.append("-O3")
+    copts.append("-fno-builtin")
 
     # We compile the code twice, the first target is suffixed with ".__internal__" and contains the
     # C++ functions in the "__llvm_libc" namespace. This allows us to test the function in the


        


More information about the libc-commits mailing list