Skip to content

[libc] Fix accidental LIBC_NAMESPACE_syscall definition #69548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

alfredfo
Copy link
Member

Building helloworld.c currently errors with "undefined symbol: __llvm_libc_syscall"

See: #67032

@gchatelet

@alfredfo
Copy link
Member Author

alfredfo commented Oct 19, 2023

libc % grep -rsin "LIBC_NAMESPACE_"
src/time/gpu/time_utils.cpp:19:    [[clang::address_space(4)]] LIBC_NAMESPACE_clock_freq = clock_freq;
src/time/gpu/time_utils.h:42:    [[clang::address_space(4)]] LIBC_NAMESPACE_clock_freq;
src/time/gpu/time_utils.h:43:#define GPU_CLOCKS_PER_SEC static_cast<clock_t>(LIBC_NAMESPACE_clock_freq)
startup/gpu/amdgpu/start.cpp:22:    [[clang::address_space(4)]] LIBC_NAMESPACE_clock_freq = 0;
test/UnitTest/LibcTest.cpp:26:    [[clang::address_space(4)]] LIBC_NAMESPACE_clock_freq;
test/UnitTest/LibcTest.cpp:27:#define CLOCKS_PER_SEC LIBC_NAMESPACE_clock_freq
utils/gpu/loader/amdgpu/Loader.cpp:480:      hsa_executable_get_symbol_by_name(executable, "LIBC_NAMESPACE_clock_freq",

I think these are also accidental

@llvmbot llvmbot added the libc label Oct 19, 2023
@alfredfo alfredfo requested a review from gchatelet October 19, 2023 01:13
@llvmbot
Copy link
Member

llvmbot commented Oct 19, 2023

@llvm/pr-subscribers-libc

Author: None (alfredfo)

Changes

Building helloworld.c currently errors with "undefined symbol: __llvm_libc_syscall"

See: #67032

@gchatelet


Full diff: https://github.com/llvm/llvm-project/pull/69548.diff

4 Files Affected:

  • (modified) libc/src/unistd/linux/syscall.cpp (+1-1)
  • (modified) libc/src/unistd/syscall.h (+1-1)
  • (modified) libc/test/src/unistd/CMakeLists.txt (+1-1)
  • (modified) libc/test/src/unistd/syscall_test.cpp (+1-1)
diff --git a/libc/src/unistd/linux/syscall.cpp b/libc/src/unistd/linux/syscall.cpp
index e1b13c9c143fa41..e0070fe6d805e3e 100644
--- a/libc/src/unistd/linux/syscall.cpp
+++ b/libc/src/unistd/linux/syscall.cpp
@@ -16,7 +16,7 @@
 
 namespace LIBC_NAMESPACE {
 
-LLVM_LIBC_FUNCTION(long, LIBC_NAMESPACE_syscall,
+LLVM_LIBC_FUNCTION(long, __llvm_libc_syscall,
                    (long number, long arg1, long arg2, long arg3, long arg4,
                     long arg5, long arg6)) {
   long ret = LIBC_NAMESPACE::syscall_impl<long>(number, arg1, arg2, arg3, arg4,
diff --git a/libc/src/unistd/syscall.h b/libc/src/unistd/syscall.h
index 255459cadb8b714..a3a4b2cb0a7b3b5 100644
--- a/libc/src/unistd/syscall.h
+++ b/libc/src/unistd/syscall.h
@@ -14,7 +14,7 @@
 
 namespace LIBC_NAMESPACE {
 
-long LIBC_NAMESPACE_syscall(long number, long arg1, long arg2, long arg3,
+long __llvm_libc_syscall(long number, long arg1, long arg2, long arg3,
                             long arg4, long arg5, long arg6);
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/test/src/unistd/CMakeLists.txt b/libc/test/src/unistd/CMakeLists.txt
index f2e2293e026f2ff..2fb11fed92b310f 100644
--- a/libc/test/src/unistd/CMakeLists.txt
+++ b/libc/test/src/unistd/CMakeLists.txt
@@ -414,7 +414,7 @@ add_libc_unittest(
     libc.include.unistd
     libc.include.fcntl
     libc.include.sys_syscall
-    libc.src.unistd.LIBC_NAMESPACE_syscall
+    libc.src.unistd.__llvm_libc_syscall
     libc.test.errno_setter_matcher
 )
 
diff --git a/libc/test/src/unistd/syscall_test.cpp b/libc/test/src/unistd/syscall_test.cpp
index 4a53f674b8f3d61..211b27c3188c4d8 100644
--- a/libc/test/src/unistd/syscall_test.cpp
+++ b/libc/test/src/unistd/syscall_test.cpp
@@ -24,7 +24,7 @@ using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
 // There is no function named "syscall" in llvm-libc, we instead use a macro to
 // set up the arguments properly. We still need to specify the namespace though
 // because the macro generates a call to the actual internal function
-// (LIBC_NAMESPACE_syscall) which is inside the namespace.
+// (__llvm_libc_syscall) which is inside the namespace.
 TEST(LlvmLibcSyscallTest, TrivialCall) {
   libc_errno = 0;
 

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collateral damage from someone doing find . -type f -exec sed -i 's/namespace __llvm_libc/namespace LIBC_NAMESPACE/g' {} \; presumably.

@github-actions
Copy link

github-actions bot commented Oct 19, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

@alfredfo alfredfo force-pushed the llvm-libc-syscallname branch from 2bcf846 to 133b12a Compare October 19, 2023 01:36
Building helloworld.c currently errors with "undefined symbol:
__llvm_libc_syscall"

See: llvm#67032
@alfredfo alfredfo force-pushed the llvm-libc-syscallname branch from 133b12a to 5596ad4 Compare October 19, 2023 01:37
@gchatelet
Copy link
Contributor

Doh! Thx for the fix!. Can you also fix the ones in #69548 (comment)?

@alfredfo
Copy link
Member Author

Sure, I'll fix it today once I'm on my desktop @gchatelet

@alfredfo alfredfo merged commit d404130 into llvm:main Oct 19, 2023
alfredfo added a commit to alfredfo/llvm-project that referenced this pull request Oct 19, 2023
alfredfo added a commit that referenced this pull request Oct 19, 2023
Guzhu-AMD pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Oct 26, 2023
Local branch amd-gfx 85fdb03 Manually merged main:416884544e02 into amd-gfx:39064028b3b3
Remote branch main d404130 [libc] Fix accidental LIBC_NAMESPACE_syscall definition (llvm#69548)
gnoliyil pushed a commit to gnoliyil/fuchsia that referenced this pull request Jan 27, 2024
…SPACE_clock_freq (#69620)

See-also: llvm/llvm-project#69548
GitOrigin-RevId: 2a373783910c8f0d858b1cf468f8ed525c6bfa8a
Original-Revision: 556c8394c08f0e457c4bb75b39f8d99ccb36853b
Roller-URL: https://ci.chromium.org/b/8766780425999225777
CQ-Do-Not-Cancel-Tryjobs: true
Change-Id: I53f56ad90159325b88c609184ff5bbf7546fea2a
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/934792
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants