[llvm-bugs] [Bug 49994] New: Baremetal builds fail as standard C library headers are imported

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 16 06:44:26 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49994

            Bug ID: 49994
           Summary: Baremetal builds fail as standard C library headers
                    are imported
           Product: compiler-rt
           Version: unspecified
          Hardware: Other
                OS: other
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: eblot.ml at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi,

I've noticed two issues while building compiler-rt for baremetal targets with
LLVM 12.0 final [sorry, no way to specify this version in the bugzilla]

I've tried to build RISCV targets, but the issues are not tied to a peculiar
baremetal architecture.

1. clearcache.c, which requires <abort.h> header is built on baremetal targets.
Something weird is that compiler-rt/lib/builtins/CMakeLists.txt does not
exclude this file from the baremetal builds, while the GN alternative does
exclude it:

CMake:
if (NOT FUCHSIA)
   set(GENERIC_SOURCES
     ${GENERIC_SOURCES}
     clear_cache.c

GN:
  if (current_os != "fuchsia" && !compiler_rt_baremetal_build) {
    sources += [ "clear_cache.c" ]
  }

A simple patch such as

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt
b/compiler-rt/lib/builtins/CMakeLists.txt
index 73b6bead8424..b46a3bfa4af2 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -244,7 +244,7 @@ if (HAVE_UNWIND_H)
   )
 endif ()

-if (NOT FUCHSIA)
+if (NOT FUCHSIA AND NOT COMPILER_RT_BAREMETAL_BUILD)
   set(GENERIC_SOURCES
     ${GENERIC_SOURCES}
     clear_cache.c

seems to fix this issue, but I'm not sure it is the proper fix. Maybe
COMPILER_RT_BAREMETAL_BUILD is not longer the proper CMake definition to use? 

2. Another C lib dependency appears in int_util.c, where <stdlib.h> is imported
even for baremetal builds, around line 57. I'm not sure how to work around this
one.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210416/4d8dfac4/attachment.html>


More information about the llvm-bugs mailing list