Skip to content

libc: Prefix RPC Status code to avoid conflict in windows build #119991

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 2 commits into from
Dec 15, 2024

Conversation

jsji
Copy link
Member

@jsji jsji commented Dec 15, 2024

Somehow conflict with define in wingdi.h.

Fix build failures:

[ 52%] Building CXX object projects/offload/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/RPC.cpp.obj
In file included from ...llvm\offload\plugins-nextgen\common\src\RPC.cpp:16:
...\llvm\libc\shared\rpc.h(48,3): error: expected identifier
48 | ERROR = 0x1000,
| ^
c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR'
118 | #define ERROR 0
| ^
...\llvm\offload\plugins-nextgen\common\src\RPC.cpp(75,17): error: expected unqualified-id
75 | return rpc::ERROR;
| ^
c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR'
118 | #define ERROR 0
| ^
2 errors generated.

Somehow conflict with define in wingdi.h.

Fix build failures:

[ 52%] Building CXX object projects/offload/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/RPC.cpp.obj
In file included from ...llvm\offload\plugins-nextgen\common\src\RPC.cpp:16:
...\llvm\libc\shared\rpc.h(48,3): error: expected identifier
   48 |   ERROR = 0x1000,
      |   ^
c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR'
  118 | #define ERROR               0
      |                             ^
...\llvm\offload\plugins-nextgen\common\src\RPC.cpp(75,17): error: expected unqualified-id
   75 |     return rpc::ERROR;
      |                 ^
c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR'
  118 | #define ERROR               0
      |                             ^
2 errors generated.
@jsji jsji requested a review from jhuber6 December 15, 2024 00:32
@jsji jsji self-assigned this Dec 15, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 15, 2024

@llvm/pr-subscribers-offload

@llvm/pr-subscribers-libc

Author: Jinsong Ji (jsji)

Changes

Somehow conflict with define in wingdi.h.

Fix build failures:

[ 52%] Building CXX object projects/offload/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/RPC.cpp.obj
In file included from ...llvm\offload\plugins-nextgen\common\src\RPC.cpp:16:
...\llvm\libc\shared\rpc.h(48,3): error: expected identifier
48 | ERROR = 0x1000,
| ^
c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR'
118 | #define ERROR 0
| ^
...\llvm\offload\plugins-nextgen\common\src\RPC.cpp(75,17): error: expected unqualified-id
75 | return rpc::ERROR;
| ^
c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR'
118 | #define ERROR 0
| ^
2 errors generated.


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

3 Files Affected:

  • (modified) libc/shared/rpc.h (+1-1)
  • (modified) libc/utils/gpu/server/rpc_server.cpp (+1-1)
  • (modified) offload/plugins-nextgen/common/src/RPC.cpp (+1-1)
diff --git a/libc/shared/rpc.h b/libc/shared/rpc.h
index 3f586744377d98..2d41b6940b64c2 100644
--- a/libc/shared/rpc.h
+++ b/libc/shared/rpc.h
@@ -45,7 +45,7 @@ namespace rpc {
 /// Generic codes that can be used whem implementing the server.
 enum Status {
   SUCCESS = 0x0,
-  ERROR = 0x1000,
+  RPC_ERROR = 0x1000,
   UNHANDLED_OPCODE = 0x1001,
 };
 
diff --git a/libc/utils/gpu/server/rpc_server.cpp b/libc/utils/gpu/server/rpc_server.cpp
index f724c5c82c4222..d2742a84ab68bd 100644
--- a/libc/utils/gpu/server/rpc_server.cpp
+++ b/libc/utils/gpu/server/rpc_server.cpp
@@ -455,7 +455,7 @@ rpc::Status handle_libc_opcodes(rpc::Server::Port &port, uint32_t num_lanes) {
   case 64:
     return handle_port_impl<64>(port);
   default:
-    return rpc::ERROR;
+    return rpc::RPC_ERROR;
   }
 }
 } // namespace rpc
diff --git a/offload/plugins-nextgen/common/src/RPC.cpp b/offload/plugins-nextgen/common/src/RPC.cpp
index 66f98e68dc4429..004f05c5042eee 100644
--- a/offload/plugins-nextgen/common/src/RPC.cpp
+++ b/offload/plugins-nextgen/common/src/RPC.cpp
@@ -72,7 +72,7 @@ static rpc::Status handle_offload_opcodes(plugin::GenericDeviceTy &Device,
   else if (NumLanes == 64)
     return handle_offload_opcodes<64>(Device, Port);
   else
-    return rpc::ERROR;
+    return rpc::RPC_ERROR;
 }
 
 RPCServerTy::RPCServerTy(plugin::GenericPluginTy &Plugin)

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.

Please prefix the rest of them.

@jsji jsji requested a review from jhuber6 December 15, 2024 00:39
@jsji
Copy link
Member Author

jsji commented Dec 15, 2024

Please prefix the rest of them.

Sure, thanks!

@jsji jsji changed the title libc: Rename ERROR to RPC_ERROR to avoid conflict in windows build libc: Prefix RPC Status code to avoid conflict in windows build Dec 15, 2024
@jsji jsji merged commit e85a9f5 into llvm:main Dec 15, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants