[all-commits] [llvm/llvm-project] 16124a: [libc] `__stack_chk_fail` baremetal dependencies (...

Petr Hosek via All-commits all-commits at lists.llvm.org
Tue Jan 2 19:58:40 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 16124a3946c7f26fa4b25a5497ab68cc417950b3
      https://github.com/llvm/llvm-project/commit/16124a3946c7f26fa4b25a5497ab68cc417950b3
  Author: Petr Hosek <phosek at google.com>
  Date:   2024-01-02 (Tue, 02 Jan 2024)

  Changed paths:
    M libc/config/baremetal/arm/entrypoints.txt
    M libc/config/baremetal/riscv/entrypoints.txt
    A libc/src/__support/OSUtil/baremetal/CMakeLists.txt
    A libc/src/__support/OSUtil/baremetal/io.h
    A libc/src/__support/OSUtil/baremetal/quick_exit.h
    M libc/src/__support/OSUtil/io.h
    M libc/src/__support/OSUtil/quick_exit.h

  Log Message:
  -----------
  [libc] `__stack_chk_fail` baremetal dependencies (#76412)

`__stack_chk_fail` uses `write_to_stderr` and `abort` but these
currently aren't included in baremetal targets resulting in a CMake
build error:

```
CMake Error at /llvm-project/libc/cmake/modules/LLVMLibCObjectRules.cmake:693 (target_link_libraries):
  Target "libc.src.stdlib.abort" of type UTILITY may not be linked into
  another target.  One may link only to INTERFACE, OBJECT, STATIC or SHARED
  libraries, or to executables with the ENABLE_EXPORTS property set.
Call Stack (most recent call first):
  /llvm-project/libc/cmake/modules/LLVMLibCObjectRules.cmake:811 (create_entrypoint_object)
  /llvm-project/libc/cmake/modules/LLVMLibCObjectRules.cmake:891 (expand_flags_for_entrypoint_object)
  /llvm-project/libc/src/compiler/generic/CMakeLists.txt:1 (add_entrypoint_object)

CMake Error at /llvm-project/libc/cmake/modules/LLVMLibCLibraryRules.cmake:5 (get_target_property):
  get_target_property() called with non-existent target
  "libc.src.__support.OSUtil.osutil".
Call Stack (most recent call first):
  /llvm-project/libc/cmake/modules/LLVMLibCLibraryRules.cmake:36 (collect_object_file_deps)
  /llvm-project/libc/cmake/modules/LLVMLibCLibraryRules.cmake:36 (collect_object_file_deps)
  /llvm-project/libc/cmake/modules/LLVMLibCLibraryRules.cmake:85 (collect_object_file_deps)
  /llvm-project/libc/lib/CMakeLists.txt:26 (add_entrypoint_library)
```

To address these errors, we need to include `abort` in the list of
baremetal entrypoints. We also need to provide `write_to_stderr`
baremetal implementation, but this is challenging since there is no
uniform way to print a message on these platforms (sometimes there may
not be any way to print a message). We instead defer to
`__libc_log_write` which can be provided by the underlying platform. We
use a similar approach for `quick_exit`, defering to
`__libc_quick_exit`.




More information about the All-commits mailing list