Error: ‘char* __llvm_libc::strcpy(char*, const char*)’ aliased to external symbol ‘strcpy’

Hi, all:

My working environment:

➜  build lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy
➜  build gcc --version 
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I failed to build llvm-project with the following ERROR messages:

[3235/11180] Building CXX object projects/libc/src/string/CMakeFiles/libc.src.string.strcpy.dir/strcpy.cpp.o
FAILED: projects/libc/src/string/CMakeFiles/libc.src.string.strcpy.dir/strcpy.cpp.o 
/usr/bin/c++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I....../llvm-project/build/projects/libc/src/string -I....../llvm-project/libc/src/string -I....../llvm-project/build/include -I....../llvm-project/llvm/include -I....../llvm-project/build/projects/libc/include -I....../llvm-project/libc -I....../llvm-project/build/projects/libc -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O2 -g -DNDEBUG -std=c++17 -fpie -ffreestanding -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -Wall -Wextra -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -DLIBC_COPT_PUBLIC_PACKAGING -MD -MT projects/libc/src/string/CMakeFiles/libc.src.string.strcpy.dir/strcpy.cpp.o -MF projects/libc/src/string/CMakeFiles/libc.src.string.strcpy.dir/strcpy.cpp.o.d -o projects/libc/src/string/CMakeFiles/libc.src.string.strcpy.dir/strcpy.cpp.o -c ....../llvm-project/libc/src/string/strcpy.cpp
In file included from ....../llvm-project/libc/src/__support/endian.h:12,
                 from ....../llvm-project/libc/src/string/memory_utils/utils.h:15,
                 from ....../llvm-project/libc/src/string/memory_utils/op_builtin.h:18,
                 from ....../llvm-project/libc/src/string/memory_utils/memcpy_implementations.h:15,
                 from ....../llvm-project/libc/src/string/strcpy.cpp:10:
....../llvm-project/libc/src/string/strcpy.cpp:17:28: error: ‘char* __llvm_libc::strcpy(char*, const char*)’ aliased to external symbol ‘strcpy’
   17 | LLVM_LIBC_FUNCTION(char *, strcpy,
      |                            ^~~~~~
....../llvm-project/libc/src/__support/common.h:30:31: note: in definition of macro ‘LLVM_LIBC_FUNCTION_IMPL’
   30 |   decltype(__llvm_libc::name) name [[gnu::alias(#name)]];                      \
      |                               ^~~~
....../llvm-project/libc/src/string/strcpy.cpp:17:1: note: in expansion of macro ‘LLVM_LIBC_FUNCTION’
   17 | LLVM_LIBC_FUNCTION(char *, strcpy,
      | ^~~~~~~~~~~~~~~~~~
....../llvm-project/libc/src/string/strcpy.cpp:17:28: warning: ‘char* __llvm_libc::strcpy(char*, const char*)’ specifies less restrictive attributes than its target ‘char* strcpy(char*, const char*)’: ‘leaf’, ‘nonnull’, ‘nothrow’ [-Wmissing-attributes]
   17 | LLVM_LIBC_FUNCTION(char *, strcpy,
      |                            ^~~~~~
....../llvm-project/libc/src/__support/common.h:30:31: note: in definition of macro ‘LLVM_LIBC_FUNCTION_IMPL’
   30 |   decltype(__llvm_libc::name) name [[gnu::alias(#name)]];                      \
      |                               ^~~~
....../llvm-project/libc/src/string/strcpy.cpp:17:1: note: in expansion of macro ‘LLVM_LIBC_FUNCTION’
   17 | LLVM_LIBC_FUNCTION(char *, strcpy,
      | ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/features.h:486,
                 from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/string.h:26,
                 from ....../llvm-project/libc/src/string/strcpy.h:12,
                 from ....../llvm-project/libc/src/string/strcpy.cpp:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:77:1: note: ‘char* __llvm_libc::strcpy(char*, const char*)’ target declared here
   77 | __NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
      | ^~~~~
[3241/11180] Building CXX object lib/Passes/CMakeFiles/LLVMPasses.dir/PassBuilderPipelines.cpp.o
In file included from ....../llvm-project/llvm/lib/Passes/PassBuilderPipelines.cpp:115:
....../llvm-project/llvm/include/llvm/Transforms/Scalar/SROA.h:96:7: warning: ‘llvm::SROAPass’ declared with greater visibility than the type of its field ‘llvm::SROAPass::SelectsToRewrite’ [-Wattributes]
   96 | class SROAPass : public PassInfoMixin<SROAPass> {
      |       ^~~~~~~~
[3242/11180] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ISelLowering.cpp.o
ninja: build stopped: subcommand failed.

Can anybody please give me a hand?

Thank you

You enabled libc in -DLLVM_ENABLE_PROJECTS. Do you have a need for the llvm libc?

1 Like

Great… I think this might be the issue. Thank you …