Skip to content

Fix diagnostics-dsym.test on mac-arm64 #99399

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
Jul 19, 2024
Merged

Conversation

zeroomega
Copy link
Contributor

The check ordering of diagnostics-dsym.test is wrong and it causes
test failure when running on mac-arm64 machine. This patch fixes it.

@zeroomega
Copy link
Contributor Author

Example of the failure:

******************** TEST 'Clang :: InstallAPI/diagnostics-dsym.test' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: rm -rf /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp
+ rm -rf /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp
RUN: at line 5: split-file /Volumes/Work/s/w/ir/x/w/llvm-llvm-project/clang/test/InstallAPI/diagnostics-dsym.test /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp
+ split-file /Volumes/Work/s/w/ir/x/w/llvm-llvm-project/clang/test/InstallAPI/diagnostics-dsym.test /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp
RUN: at line 8: /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/bin/clang --target=arm64-apple-macos11 -g -dynamiclib /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.c  -current_version 1 -compatibility_version 1 -L/Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/usr/lib  -save-temps -dynamiclib  -o /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib -install_name /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib
+ /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/bin/clang --target=arm64-apple-macos11 -g -dynamiclib /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.c -current_version 1 -compatibility_version 1 -L/Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/usr/lib -save-temps -dynamiclib -o /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib -install_name /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib
RUN: at line 12: dsymutil /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib -o /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dSYM
+ dsymutil /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib -o /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dSYM
RUN: at line 14: not /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/bin/clang-installapi -x c++ --target=arm64-apple-macos11  -install_name /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib   -current_version 1 -compatibility_version 1  -o /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/output.tbd -dynamiclib  --verify-against=/Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib --dsym=/Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dSYM  --verify-mode=Pedantic 2>&1 | /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/bin/FileCheck /Volumes/Work/s/w/ir/x/w/llvm-llvm-project/clang/test/InstallAPI/diagnostics-dsym.test
+ not /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/bin/clang-installapi -x c++ --target=arm64-apple-macos11 -install_name /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib -current_version 1 -compatibility_version 1 -o /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/output.tbd -dynamiclib --verify-against=/Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dylib --dsym=/Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.dSYM --verify-mode=Pedantic
+ /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/bin/FileCheck /Volumes/Work/s/w/ir/x/w/llvm-llvm-project/clang/test/InstallAPI/diagnostics-dsym.test
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/clang/test/InstallAPI/diagnostics-dsym.test:23:10: error: CHECK: expected string not found in input
; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in dynamic library
         ^
<stdin>:3:205: note: scanning from here
/Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.c:5:0: error: no declaration found for exported symbol 'bar' in dynamic library
                                                                                                                                                                                                            ^

Input file: <stdin>
Check file: /Volumes/Work/s/w/ir/x/w/llvm-llvm-project/clang/test/InstallAPI/diagnostics-dsym.test

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

Input was:
<<<<<<
          1: warning: violations found for arm64 [-Winstallapi-violation] 
          2: /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.c:1:0: error: no declaration found for exported symbol 'foo' in dynamic library 
          3: /Volumes/Work/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/tools/clang/test/InstallAPI/Output/diagnostics-dsym.test.tmp/foo.c:5:0: error: no declaration found for exported symbol 'bar' in dynamic library 
check:23                                                                                                                                                                                                                 X error: no match found
>>>>>>

--

********************

After this patch. It passes.

@zeroomega zeroomega marked this pull request as ready for review July 17, 2024 22:50
@zeroomega zeroomega requested a review from cyndyishida as a code owner July 17, 2024 22:50
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jul 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 17, 2024

@llvm/pr-subscribers-clang

Author: Haowei (zeroomega)

Changes

The check ordering of diagnostics-dsym.test is wrong and it causes
test failure when running on mac-arm64 machine. This patch fixes it.


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

1 Files Affected:

  • (modified) clang/test/InstallAPI/diagnostics-dsym.test (+1-1)
diff --git a/clang/test/InstallAPI/diagnostics-dsym.test b/clang/test/InstallAPI/diagnostics-dsym.test
index 42fa67a1f9b1e..fb760d1858ba3 100644
--- a/clang/test/InstallAPI/diagnostics-dsym.test
+++ b/clang/test/InstallAPI/diagnostics-dsym.test
@@ -19,8 +19,8 @@
 ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s
 
 ; CHECK: violations found for arm64 
-; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in dynamic library
 ; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in dynamic library
+; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in dynamic library
 
 ;--- foo.c
 int foo(void) {

@zeroomega zeroomega requested a review from petrhosek July 17, 2024 23:03
@cyndyishida
Copy link
Member

Thank you @zeroomega ! I am also running on arm64-mac and that test is passing. What is your cmake invocation? I'd like to dig into the underlying cause of non-stable ordering. It looks like the darwin-aarch64 is passing the test as well https://lab.llvm.org/buildbot/#/builders/190
In general, though, I'm not too worried about the ordering of diagnostics so maybe a CHECK-DAG would make the test resilient

@zeroomega
Copy link
Contributor Author

zeroomega commented Jul 18, 2024

Thank you @zeroomega ! I am also running on arm64-mac and that test is passing. What is your cmake invocation? I'd like to dig into the underlying cause of non-stable ordering. It looks like the darwin-aarch64 is passing the test as well https://lab.llvm.org/buildbot/#/builders/190 In general, though, I'm not too worried about the ordering of diagnostics so maybe a CHECK-DAG would make the test resilient

Our build is a bit complicated to setup since we use a clang (near tip of the tree) which linked to llvm-libcxx, as the host toolchain. But when I try to build the clang with the toolchain came with the xcode, the original test file passed, and after I swapped the ordering, it failed. So apparently the output ordering is a bit non-deterministic. And since bar is used later than foo, so natually foo should comes first and bar comes later. My guess is that underlying data structure for the symbols is probably using a C++ standard library and it has different implementation from libcxx and whatever was provided by xcode.

Let me test the CHECK-DAG solution locally and update my patch. I think that is a better solution.

The output ordering of diagnostics-dsym.test is non-deterministic,
which cases test failures on mac-arm64 when using some toolchains that
are not shipped from the xcode. This patch change the 'CHECK' to
'CHECK-DAG' to mitigate this issue.
@zeroomega
Copy link
Contributor Author

@cyndyishida I updated the patch to use CHECK-DAG and confirm the test now pass under both XCode toolchain and our in house one. Please take a look. Thx.

Copy link
Member

@cyndyishida cyndyishida left a comment

Choose a reason for hiding this comment

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

Thank you for looking into & resolving this again!

@zeroomega zeroomega merged commit 2df9fd7 into llvm:main Jul 19, 2024
7 checks passed
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
The check ordering of diagnostics-dsym.test is wrong and it causes
test failure when running on mac-arm64 machine. This patch fixes it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants