Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cross-project-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ add_llvm_executable(check-gdb-llvm-support
)
target_link_libraries(check-gdb-llvm-support PRIVATE LLVMSupport)

add_executable(check-lldb-llvm-support-arrayref
debuginfo-tests/llvm-prettyprinters/lldb/arrayref.cpp
)
target_link_libraries(check-lldb-llvm-support-arrayref PRIVATE LLVMSupport)
target_compile_options(check-lldb-llvm-support-arrayref PRIVATE -g -O0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hello @Michael137

I noticed that if you compile with -D_FORTIFY_SOURCE=2 we now get

In file included from /app/gcc/14.2.0/include/c++/14.2.0/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /app/gcc/14.2.0/include/c++/14.2.0/x86_64-pc-linux-gnu/bits/c++config.h:680,
                 from /app/gcc/14.2.0/include/c++/14.2.0/type_traits:38,
                 from ../include/llvm/ADT/ADL.h:12,
                 from ../include/llvm/ADT/Hashing.h:47,
                 from ../include/llvm/ADT/ArrayRef.h:12,
                 from ../../cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/arrayref.cpp:1:
/usr/include/features.h:381:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  381 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~

when compiling cross-project-tests. And if compiling with -Werror, the build then fails.

I suppose it's because of the hardcoded "-O0" in the config above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the ping. Not sure off the top how to best handle this but I'll have a look

Copy link
Collaborator

Choose a reason for hiding this comment

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

Downstream I worked around it by undefining _FORTIFY_SOURCE when we add -O0 like

-target_compile_options(check-lldb-llvm-support-arrayref PRIVATE -g -O0)
+target_compile_options(check-lldb-llvm-support-arrayref PRIVATE -g -O0 -U_FORTIFY_SOURCE)

but I don't know if there is anything better that can be done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Heh yea maybe that's worth a shot, thanks! I'll put up a review

Copy link
Member Author

Choose a reason for hiding this comment

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


set(CROSS_PROJECT_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CROSS_PROJECT_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

set(CROSS_PROJECT_TEST_DEPS
FileCheck
check-gdb-llvm-support
check-lldb-llvm-support-arrayref
count
llvm-ar
llvm-config
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "llvm/ADT/ArrayRef.h"

int Array[] = {1, 2, 3};

llvm::ArrayRef<int> ArrayRef(Array);
llvm::MutableArrayRef<int> MutableArrayRef(Array);

int main() { return 0; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# RUN: split-file %s %t
# RUN: lldb -b -x -o 'command script import %llvm_src_root/utils/lldbDataFormatters.py' -s %t/commands.input %llvm_tools_dir/check-lldb-llvm-support-arrayref | FileCheck %t/checks

#--- commands.input
b main
run
p ArrayRef
p MutableArrayRef

#--- checks
# CHECK: (lldb) p ArrayRef
# CHECK-NEXT: (llvm::ArrayRef<int>) size=3 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @Michael137

I randomly see this testcase failing on a downstream build bot. I've seen failures like this:

/repo/llvm/build-all-builtins/projects/cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/Output/arrayref.test.tmp/checks:2:15: error: CHECK-NEXT: is not on the line after the previous match
# CHECK-NEXT: (llvm::ArrayRef<int>) size=3 {
              ^
<stdin>:20:1: note: 'next' match was here
(llvm::ArrayRef<int>) size=3 {
^
<stdin>:18:18: note: previous match ended here
(lldb) p ArrayRef
                 ^
<stdin>:19:1: note: non-matching line after previous match is here
1 location added to breakpoint 1
^

Input file: <stdin>
Check file: /repo/llvm/build-all-builtins/projects/cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/Output/arrayref.test.tmp/checks

-dump-input=help explains the following input dump.

Input was:
<<<<<<
        .
        .
        .
       15:  7  
       16: -> 8 int main() { return 0; } 
       17:  ^ 
       18: (lldb) p ArrayRef 
       19: 1 location added to breakpoint 1 
       20: (llvm::ArrayRef<int>) size=3 { 
next:2     !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  error: match on wrong line
       21:  [0] = 1 
       22:  [1] = 2 
       23:  [2] = 3 
       24: } 
       25: (lldb) p MutableArrayRef 
        .
        .
        .
>>>>>>

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

1 warning(s) in tests
********************
Failed Tests (1):
  cross-project-tests :: debuginfo-tests/llvm-prettyprinters/lldb/arrayref.test

so there something unexpected between the expected lines in the output.
It happens now and then. Any idea what the problem is and if it can be fixed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm interesting, looks like it's this:

1 location added to breakpoint 1

That would happen on Linux when LLDB finds the breakpoint on main when the process is launched. Might be due to machine load/LLDB sluggishness that the output is printed later than expected. We can probably remove the check for p ArrayRef. Or not make it a CHECK-NEXT.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks. I'll keep an eye on our build bot and get back if we see any more flakiness after that.

# CHECK-NEXT: [0] = 1
# CHECK-NEXT: [1] = 2
# CHECK-NEXT: [2] = 3
# CHECK-NEXT: }

# CHECK: (lldb) p MutableArrayRef
# CHECK-NEXT: (llvm::MutableArrayRef<int>) {
# CHECK-NEXT: llvm::ArrayRef<int> = size=3 {
# CHECK-NEXT: [0] = 1
# CHECK-NEXT: [1] = 2
# CHECK-NEXT: [2] = 3
# CHECK-NEXT: }
# CHECK-NEXT: }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import lit.util

if "native" not in config.available_features or lit.util.which("lldb") is None:
config.unsupported = True

config.suffixes = [".test"]
Loading