Skip to content

Conversation

@zibi2
Copy link
Contributor

@zibi2 zibi2 commented Sep 23, 2025

On z/OS strnlen() is not available by default so we use the wrapper header zOSSupport.h to make it visible. This will fix the following error:

clang/lib/AST/ByteCode/Context.cpp:250:16: error: use of undeclared identifier 'strnlen'
  250 |       Result = strnlen(reinterpret_cast<const char *>(Ptr.getRawAddress()), N);
      |                ^~~~~~~
1 error generated.

@zibi2 zibi2 self-assigned this Sep 23, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Sep 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 23, 2025

@llvm/pr-subscribers-clang

Author: Zibi Sarbinowski (zibi2)

Changes

On z/OS strnlen() is not available by default so we use the wrapper header zOSSupport.h to make it visible. This will fix the following error:

clang/lib/AST/ByteCode/Context.cpp:250:16: error: use of undeclared identifier 'strnlen'
  250 |       Result = strnlen(reinterpret_cast&lt;const char *&gt;(Ptr.getRawAddress()), N);
      |                ^~~~~~~
1 error generated.

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

1 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Context.cpp (+1)
diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp
index 8860bcc54a9c1..71d0bcf61a5ff 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/Expr.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/Support/SystemZ/zOSSupport.h"
 
 using namespace clang;
 using namespace clang::interp;

@cor3ntin cor3ntin requested a review from tbaederr September 23, 2025 16:59
#include "clang/AST/ASTLambda.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will get deleted again. The compiles on other platforms are going to say this header is empty and it will get removed again.

What I was thinking should do is:

  1. create a wrapper header dir that is just for building llvm. This can live in the llvm repo (or we prereq the zoslib repo which has this already)
  • create a stdlib.h that has the strnlen() in it
  1. add a -isystem option to include this wrapper.

I'm good with the change. Just worried it will get undone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for suggestion.

This header is included in 1/2 a dozen places and it was not removed so far but when it does I will look into your suggestion.

@zibi2 zibi2 merged commit 55f230f into llvm:main Sep 23, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants