Page MenuHomePhabricator

Clang IFSO driver action.
ClosedPublic

Authored by plotfi on Apr 22 2019, 11:24 AM.

Diff Detail

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
rupprecht added inline comments.Jun 7 2019, 1:27 PM
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
243

elsewhere it looks like this was changed to "ifs"?

plotfi updated this revision to Diff 203638.Jun 7 2019, 3:43 PM

-U999999

plotfi updated this revision to Diff 204187.Jun 11 2019, 4:04 PM
plotfi marked 11 inline comments as done.

addressing @rupprecht's feedback

plotfi marked 3 inline comments as done.Jun 11 2019, 4:05 PM

Can you upload this patch with context? Either use arc or upload w/ -U99999

Thanks for the review.

I seem to have a lot of comments, but they're all nits -- my major concern being the llvm_unreachables should be errors instead (i.e. should be triggered in release builds).

Since this is clearly labeled as experimental, I think you should feel free to commit if you can get another lgtm (@compnerd?)

clang/lib/Driver/ToolChains/Clang.cpp
3614–3616

But what if it is set to something that's not either experimental-yaml-elf-v1 or experimental-tapi-elf-v1? This was to truncate any values that aren't those two to "" so that the error check could just be if (StubFormat.empty()). Maybe something other than a string switch would have been more explicit.

clang/lib/Frontend/CompilerInvocation.cpp
1688

AH yes, you are right. This should probably be a diag. (clang/test/InterfaceStubs/bad-format.cpp tests for this "unreachable").

clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
42

llvm::is_contained does not appear to work with std::map. I will try to figure out why.

plotfi updated this revision to Diff 204308.Jun 12 2019, 9:26 AM
plotfi marked 2 inline comments as done.

Improving support for visibility correctness with classes, methods and inheritance.

compnerd added inline comments.Jun 12 2019, 9:55 AM
clang/lib/Frontend/CompilerInvocation.cpp
1690

I think you could've used a llvm::Optional.

clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
22

An enumeration may be nicer.

40

I tend to prefer if (RDO & ~FromTU)

57

Why not if (ND->getVisibility() == DefaultVisibility) return true;?

66

I think that using something like ignoreDecl is better than doBail.

69

A newline before this would be nice.

73

If it is a VarDecl, it cannot be a FunctionDecl. I think that this can be simplified a bit as:

if (const auto *VD = dyn_cast<VarDecl>(VD))
  return VD->getStorageClass() == StorageClass::SC_Extern ||
      VD->getStorageClass() == StorageClass::SC_Static ||
      VD->getParentFunctionOrMethod() == nullptr;
74

Newline before this would be nice. I think that using auto here for the type is fine as you spelt out the type in the dyn_cast.

78

I think that flipping this around would be nicer.

if (const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
  ...
}

return FD->isInlined() && !Instance.getLangOpts().GNUInline;
80

CTD is not used, please use isa and avoid the unused variable warning.

119

Can we compress getMangledName and getMangledNames into getMangledNames and always return the vector? This avoids the duplication and simplifies the symbol recording later as well.

151

You can probably hoist this to L129, and avoid the variable definition and the check on L131.

plotfi updated this revision to Diff 204978.Jun 16 2019, 5:06 PM
plotfi marked 17 inline comments as done.

Addressing @compnerd's feedback

plotfi added inline comments.Jun 16 2019, 5:07 PM
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
22

For now the format goes into the first line of the yaml (in both formats) and ends up as "--- ! <Format>\n".
I'd like to keep it this way for now.

40

0 != (RDO & 0x1) vs (RDO & 0xE)

I'm not sure if these are logically equivalent

73

I don't understand. Here I remember wanting to bail if VD->getParentFunctionOrMethod() == nullptr and the vardecl was marked static.

78

I think this still causes the isInlined + !GNUInlined code to trigger on CXXMethodDecls.

compnerd accepted this revision.Jun 17 2019, 12:59 PM
compnerd added inline comments.
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
92

I don't understand this clause. The structurors will always have 2 manglings (both itanium and MSVC use multiple, I don't remember the SUN and GNU variants off the top of my head). Adding the assert for the non-structor case is fine, but please wrap the entire thing in an LLVM_EXPENSIVE_ASSERT.

117

This really should emit a diagnostic. The CompilerInstance should have a reference to the DiagnosticsEngine.

This revision is now accepted and ready to land.Jun 17 2019, 12:59 PM
plotfi updated this revision to Diff 205191.Jun 17 2019, 3:07 PM
plotfi marked 2 inline comments as done.
This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.Jun 17 2019, 7:05 PM
cfe/trunk/lib/Frontend/CMakeLists.txt
58 ↗(On Diff #205203)

This is a layering issue. clangIndex depends on clangFrontend so clangFrontend should not depend on clangIndex.

The circular dependency is allowed for static libraries but it breaks -DBUILD_SHARED_LIBS=on:

CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):    
  "clangFrontend" of type SHARED_LIBRARY
    depends on "clangIndex" (weak)
  "clangIndex" of type SHARED_LIBRARY
    depends on "clangFrontend" (weak)
At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.
plotfi marked an inline comment as done.Jun 17 2019, 7:10 PM
plotfi added inline comments.
cfe/trunk/lib/Frontend/CMakeLists.txt
58 ↗(On Diff #205203)

Is there a bot affected by this? I will take a look.

MaskRay added inline comments.Jun 17 2019, 7:11 PM
cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
22 ↗(On Diff #205203)

Does StringSet<> work?

36 ↗(On Diff #205203)

Are you relying on the ordered property of std::map?

101 ↗(On Diff #205203)

.count

103 ↗(On Diff #205203)

This should be a TODO

124 ↗(On Diff #205203)

If you use a llvm container, emplace or try_emplace

plotfi marked 3 inline comments as done.Jun 17 2019, 7:17 PM
plotfi added inline comments.
cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
22 ↗(On Diff #205203)

It probably could work. I will likely follow up with an NFC patch for this.

36 ↗(On Diff #205203)

No I am not.

101 ↗(On Diff #205203)

Nice.

asb added a subscriber: asb.Jun 17 2019, 9:25 PM
asb added inline comments.
cfe/trunk/lib/Frontend/CMakeLists.txt
58 ↗(On Diff #205203)

Sadly there is no -DBUILD_SHARED_LIBS=True bot. This layering issue will break builds for all downstream users using that option though.

plotfi marked 3 inline comments as done.Jun 17 2019, 9:37 PM
plotfi added inline comments.
cfe/trunk/lib/Frontend/CMakeLists.txt
58 ↗(On Diff #205203)

Just checking (to see if there is a bot to verify with). I have a fix (removing clangIndex) that I think will build with or without -DBUILD_SHARED_LIBS=ON.

58 ↗(On Diff #205203)

I've updated cfe/trunk/lib/Frontend/CMakeLists.txt in r363646

plotfi marked 2 inline comments as done.Jun 17 2019, 9:38 PM

I had to back out r363646. While it worked for me building locally with and without shared lib, it appears to have caused bots to break. I will take another look at fixing it in about 10 hours.

MaskRay added inline comments.Jun 17 2019, 10:19 PM
cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
12 ↗(On Diff #205203)

rL363646

This file references symbols from clangIndex (#include "clang/Index/CodegenNameGenerator.h"), so you can't remove the clangIndex dependency from CMakeFiles.txt, otherwise -DBUILD_SHARED_LIBS=off builds would also fail.

# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
# build might work on ELF but fail on MachO/COFF.

The built shared library must have all of its dependencies specified on the linker command line.

@plotfi Sorry I have to revert this patch. This can also cause problems in -DBUILD_SHARED_LIBS=off builds. clangFrontend files cannot #include "clang/Index/CodegenNameGenerator.h", I think you may have to move files around.

@plotfi Sorry I have to revert this patch. This can also cause problems in -DBUILD_SHARED_LIBS=off builds. clangFrontend files cannot #include "clang/Index/CodegenNameGenerator.h", I think you may have to move files around.

That’s fine. I will coordinate with you when I attempt to re-land.

plotfi updated this revision to Diff 205686.Jun 19 2019, 3:27 PM

This should address the shared lib issue.

This was re-landed in r363948

ymandel added a subscriber: ymandel.Jul 1 2019, 8:48 AM

The tests for this code are failing in my build. Any suggestions welcome.

My setup:

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang-7 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-7 -DCMAKE_C_FLAGS='-gmlt -Wall' -DCMAKE_CXX_FLAGS='-gmlt -Wall' -DLLVM_PARALLEL_LINK_JOBS=6 -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra' ../llvm-project/llvm

with head at:

commit 3b7668ae4bb8fabf95bd78dc6a06ca75f6ec3958 (HEAD, origin/master, origin/HEAD)
Author: Matt Arsenault <Matthew.Arsenault@amd.com>
Date:   Mon Jul 1 13:34:26 2019 +0000

    AMDGPU/GlobalISel: Improve icmp selection coverage.
    
    Select s64 eq/ne scalar icmp.
    
    llvm-svn: 364765

The failures:

ninja check-clang
[3586/3587] Running the Clang regression tests
llvm-lit: <...>/llvm-project/llvm/utils/lit/lit/llvm/config.py:340: note: using clang: <...>/build/bin/clang
FAIL: Clang :: InterfaceStubs/virtual.cpp (6035 of 15113)
******************** TEST 'Clang :: InterfaceStubs/virtual.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
: 'RUN: at line 5';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI2 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
: 'RUN: at line 8';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  llvm-readelf -s - 2>&1 | <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp:16:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: NOTYPE GLOBAL HIDDEN {{.*}} _ZNK1Q5func1Ev
                      ^
<stdin>:1:1: note: scanning from here
There are 28 section headers, starting at offset 0x718:
^
<stdin>:4:25: note: possible intended match here
 [Nr] Name Type Address Off Size ES Flg Lk Inf Al
                        ^

--

********************
FAIL: Clang :: InterfaceStubs/class-template-specialization.cpp (6041 of 15113)
******************** TEST 'Clang :: InterfaceStubs/class-template-specialization.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
: 'RUN: at line 6';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI2 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
: 'RUN: at line 9';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp:26:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: FUNC GLOBAL DEFAULT {{[0-9]}} _Z1g
                      ^
<stdin>:1:1: note: scanning from here
There are 12 section headers, starting at offset 0x2a8:
^
<stdin>:7:41: note: possible intended match here
 [ 2] .text PROGBITS 0000000000000000 000040 000017 00 AX 0 0 16
                                        ^

--

********************
FAIL: Clang :: InterfaceStubs/hidden-class-inheritance.cpp (6044 of 15113)
******************** TEST 'Clang :: InterfaceStubs/hidden-class-inheritance.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-X <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 7';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-X-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 13';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 18';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP2 <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 23';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 29';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 34';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC2 <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 39';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 45';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-HC <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 50';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-HC-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp:65:16: error: CHECK-X-RE: expected string not found in input
// CHECK-X-RE: FUNC WEAK DEFAULT {{[0-9]+}} _ZN1C1mEv
               ^
<stdin>:1:1: note: scanning from here
There are 48 section headers, starting at offset 0xdb0:
^
<stdin>:7:48: note: possible intended match here
 [ 2] .text PROGBITS 0000000000000000 000040 00005c 00 AX 0 0 16
                                               ^

--

********************
FAIL: Clang :: InterfaceStubs/visibility.cpp (6110 of 15113)
******************** TEST 'Clang :: InterfaceStubs/visibility.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden  <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | <...>/build/bin/FileCheck --check-prefix=CHECK-CMD-HIDDEN <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 6';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 -fvisibility=hidden  <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | <...>/build/bin/FileCheck --check-prefix=CHECK-CMD-HIDDEN <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 10';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 14';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 18';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD2 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 22';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD2 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 26';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp:44:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: DEFAULT {{.*}} _Z10cmdVisiblev
                      ^
<stdin>:1:1: note: scanning from here
There are 9 section headers, starting at offset 0x2a8:
^
<stdin>:4:34: note: possible intended match here
 [Nr] Name Type Address Off Size ES Flg Lk Inf Al
                                 ^

--

********************
Testing Time: 34.72s
********************
Failing Tests (4):
    Clang :: InterfaceStubs/class-template-specialization.cpp
    Clang :: InterfaceStubs/hidden-class-inheritance.cpp
    Clang :: InterfaceStubs/virtual.cpp
    Clang :: InterfaceStubs/visibility.cpp

  Expected Passes    : 14989
  Expected Failures  : 21
  Unsupported Tests  : 99
  Unexpected Failures: 4
FAILED: tools/clang/test/CMakeFiles/check-clang

where <...> stands for my local clang repo directory.

plotfi added a comment.Jul 1 2019, 9:26 AM

The tests for this code are failing in my build. Any suggestions welcome.

My setup:

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang-7 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-7 -DCMAKE_C_FLAGS='-gmlt -Wall' -DCMAKE_CXX_FLAGS='-gmlt -Wall' -DLLVM_PARALLEL_LINK_JOBS=6 -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra' ../llvm-project/llvm

with head at:

commit 3b7668ae4bb8fabf95bd78dc6a06ca75f6ec3958 (HEAD, origin/master, origin/HEAD)
Author: Matt Arsenault <Matthew.Arsenault@amd.com>
Date:   Mon Jul 1 13:34:26 2019 +0000

    AMDGPU/GlobalISel: Improve icmp selection coverage.
    
    Select s64 eq/ne scalar icmp.
    
    llvm-svn: 364765

The failures:

ninja check-clang
[3586/3587] Running the Clang regression tests
llvm-lit: <...>/llvm-project/llvm/utils/lit/lit/llvm/config.py:340: note: using clang: <...>/build/bin/clang
FAIL: Clang :: InterfaceStubs/virtual.cpp (6035 of 15113)
******************** TEST 'Clang :: InterfaceStubs/virtual.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
: 'RUN: at line 5';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI2 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
: 'RUN: at line 8';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  llvm-readelf -s - 2>&1 | <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp:16:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: NOTYPE GLOBAL HIDDEN {{.*}} _ZNK1Q5func1Ev
                      ^
<stdin>:1:1: note: scanning from here
There are 28 section headers, starting at offset 0x718:
^
<stdin>:4:25: note: possible intended match here
 [Nr] Name Type Address Off Size ES Flg Lk Inf Al
                        ^

--

********************
FAIL: Clang :: InterfaceStubs/class-template-specialization.cpp (6041 of 15113)
******************** TEST 'Clang :: InterfaceStubs/class-template-specialization.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
: 'RUN: at line 6';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI2 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
: 'RUN: at line 9';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp:26:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: FUNC GLOBAL DEFAULT {{[0-9]}} _Z1g
                      ^
<stdin>:1:1: note: scanning from here
There are 12 section headers, starting at offset 0x2a8:
^
<stdin>:7:41: note: possible intended match here
 [ 2] .text PROGBITS 0000000000000000 000040 000017 00 AX 0 0 16
                                        ^

--

********************
FAIL: Clang :: InterfaceStubs/hidden-class-inheritance.cpp (6044 of 15113)
******************** TEST 'Clang :: InterfaceStubs/hidden-class-inheritance.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-X <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 7';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-X-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 13';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 18';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP2 <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 23';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 29';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 34';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC2 <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 39';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 45';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-HC <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 50';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-HC-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp:65:16: error: CHECK-X-RE: expected string not found in input
// CHECK-X-RE: FUNC WEAK DEFAULT {{[0-9]+}} _ZN1C1mEv
               ^
<stdin>:1:1: note: scanning from here
There are 48 section headers, starting at offset 0xdb0:
^
<stdin>:7:48: note: possible intended match here
 [ 2] .text PROGBITS 0000000000000000 000040 00005c 00 AX 0 0 16
                                               ^

--

********************
FAIL: Clang :: InterfaceStubs/visibility.cpp (6110 of 15113)
******************** TEST 'Clang :: InterfaceStubs/visibility.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden  <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | <...>/build/bin/FileCheck --check-prefix=CHECK-CMD-HIDDEN <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 6';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 -fvisibility=hidden  <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | <...>/build/bin/FileCheck --check-prefix=CHECK-CMD-HIDDEN <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 10';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 14';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 18';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD2 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 22';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD2 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 26';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp:44:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: DEFAULT {{.*}} _Z10cmdVisiblev
                      ^
<stdin>:1:1: note: scanning from here
There are 9 section headers, starting at offset 0x2a8:
^
<stdin>:4:34: note: possible intended match here
 [Nr] Name Type Address Off Size ES Flg Lk Inf Al
                                 ^

--

********************
Testing Time: 34.72s
********************
Failing Tests (4):
    Clang :: InterfaceStubs/class-template-specialization.cpp
    Clang :: InterfaceStubs/hidden-class-inheritance.cpp
    Clang :: InterfaceStubs/virtual.cpp
    Clang :: InterfaceStubs/visibility.cpp

  Expected Passes    : 14989
  Expected Failures  : 21
  Unsupported Tests  : 99
  Unexpected Failures: 4
FAILED: tools/clang/test/CMakeFiles/check-clang

where <...> stands for my local clang repo directory.

I will take a look. Thanks for the cmake command line.

PL

The tests for this code are failing in my build. Any suggestions welcome.

My setup:

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang-7 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-7 -DCMAKE_C_FLAGS='-gmlt -Wall' -DCMAKE_CXX_FLAGS='-gmlt -Wall' -DLLVM_PARALLEL_LINK_JOBS=6 -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra' ../llvm-project/llvm

with head at:

commit 3b7668ae4bb8fabf95bd78dc6a06ca75f6ec3958 (HEAD, origin/master, origin/HEAD)
Author: Matt Arsenault <Matthew.Arsenault@amd.com>
Date:   Mon Jul 1 13:34:26 2019 +0000

    AMDGPU/GlobalISel: Improve icmp selection coverage.
    
    Select s64 eq/ne scalar icmp.
    
    llvm-svn: 364765

The failures:

ninja check-clang
[3586/3587] Running the Clang regression tests
llvm-lit: <...>/llvm-project/llvm/utils/lit/lit/llvm/config.py:340: note: using clang: <...>/build/bin/clang
FAIL: Clang :: InterfaceStubs/virtual.cpp (6035 of 15113)
******************** TEST 'Clang :: InterfaceStubs/virtual.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
: 'RUN: at line 5';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI2 <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
: 'RUN: at line 8';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp |  llvm-readelf -s - 2>&1 | <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/virtual.cpp:16:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: NOTYPE GLOBAL HIDDEN {{.*}} _ZNK1Q5func1Ev
                      ^
<stdin>:1:1: note: scanning from here
There are 28 section headers, starting at offset 0x718:
^
<stdin>:4:25: note: possible intended match here
 [Nr] Name Type Address Off Size ES Flg Lk Inf Al
                        ^

--

********************
FAIL: Clang :: InterfaceStubs/class-template-specialization.cpp (6041 of 15113)
******************** TEST 'Clang :: InterfaceStubs/class-template-specialization.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
: 'RUN: at line 6';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-TAPI2 <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
: 'RUN: at line 9';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp:26:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: FUNC GLOBAL DEFAULT {{[0-9]}} _Z1g
                      ^
<stdin>:1:1: note: scanning from here
There are 12 section headers, starting at offset 0x2a8:
^
<stdin>:7:41: note: possible intended match here
 [ 2] .text PROGBITS 0000000000000000 000040 000017 00 AX 0 0 16
                                        ^

--

********************
FAIL: Clang :: InterfaceStubs/hidden-class-inheritance.cpp (6044 of 15113)
******************** TEST 'Clang :: InterfaceStubs/hidden-class-inheritance.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-X <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 7';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-X-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 13';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 18';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP2 <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 23';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=""  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 29';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 34';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC2 <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 39';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HC-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 45';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-HC <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
: 'RUN: at line 50';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c  -DPARENT_CLASS_VISIBILITY=HIDDEN -DCHILD_CLASS_VISIBILITY=HIDDEN  -DPARENT_METHOD_VISIBILITY="" -DCHILD_METHOD_VISIBILITY="" <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp |  llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-HP-HC-RE <...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/hidden-class-inheritance.cpp:65:16: error: CHECK-X-RE: expected string not found in input
// CHECK-X-RE: FUNC WEAK DEFAULT {{[0-9]+}} _ZN1C1mEv
               ^
<stdin>:1:1: note: scanning from here
There are 48 section headers, starting at offset 0xdb0:
^
<stdin>:7:48: note: possible intended match here
 [ 2] .text PROGBITS 0000000000000000 000040 00005c 00 AX 0 0 16
                                               ^

--

********************
FAIL: Clang :: InterfaceStubs/visibility.cpp (6110 of 15113)
******************** TEST 'Clang :: InterfaceStubs/visibility.cpp' FAILED ********************
Script:
--
: 'RUN: at line 2';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden  <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | <...>/build/bin/FileCheck --check-prefix=CHECK-CMD-HIDDEN <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 6';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 -fvisibility=hidden  <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | <...>/build/bin/FileCheck --check-prefix=CHECK-CMD-HIDDEN <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 10';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 14';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 18';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-tapi-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD2 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 22';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs  -interface-stub-version=experimental-yaml-elf-v1 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp |  <...>/build/bin/FileCheck --check-prefix=CHECK-CMD2 <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
: 'RUN: at line 26';   <...>/build/bin/clang -target x86_64-unknown-linux-gnu -o - -c <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp | llvm-readelf -s - 2>&1 |  <...>/build/bin/FileCheck -check-prefix=CHECK-SYMBOLS <...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp
--
Exit Code: 1

Command Output (stderr):
--
<...>/llvm-project/clang/test/InterfaceStubs/visibility.cpp:44:23: error: CHECK-SYMBOLS-DAG: expected string not found in input
// CHECK-SYMBOLS-DAG: DEFAULT {{.*}} _Z10cmdVisiblev
                      ^
<stdin>:1:1: note: scanning from here
There are 9 section headers, starting at offset 0x2a8:
^
<stdin>:4:34: note: possible intended match here
 [Nr] Name Type Address Off Size ES Flg Lk Inf Al
                                 ^

--

********************
Testing Time: 34.72s
********************
Failing Tests (4):
    Clang :: InterfaceStubs/class-template-specialization.cpp
    Clang :: InterfaceStubs/hidden-class-inheritance.cpp
    Clang :: InterfaceStubs/virtual.cpp
    Clang :: InterfaceStubs/visibility.cpp

  Expected Passes    : 14989
  Expected Failures  : 21
  Unsupported Tests  : 99
  Unexpected Failures: 4
FAILED: tools/clang/test/CMakeFiles/check-clang

where <...> stands for my local clang repo directory.

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

Right -- no, I'm not. I explicitly added the llvm-7 bin to my path because without it, those tests fail with:

build/tools/clang/test/InterfaceStubs/Output/visibility.cpp.script: line 7: llvm-readelf: command not found

Sorry I didn't mention this up front. I've never needed llvm-readelf before -- what is the standard way to build/install from git?

ninja install did the trick. Thanks for your help!

jfb added a subscriber: jfb.Jul 1 2019, 2:58 PM

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

Please don't do this. Your commit is wrong, and the right action from you is to revert it or fix it. I've fixed it for you here: rL364855

jfb added a comment.Jul 1 2019, 3:01 PM
In D60974#1565517, @jfb wrote:

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

Please don't do this. Your commit is wrong, and the right action from you is to revert it or fix it. I've fixed it for you here: rL364855

I'm also really not sure this is any good: why does clang look at ELF? In general I'd expect you to test something *way* earlier than ELF. Are you sure you're testing the right thing?

plotfi added a comment.Jul 1 2019, 3:07 PM
In D60974#1565527, @jfb wrote:
In D60974#1565517, @jfb wrote:

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

Please don't do this. Your commit is wrong, and the right action from you is to revert it or fix it. I've fixed it for you here: rL364855

I'm also really not sure this is any good: why does clang look at ELF? In general I'd expect you to test something *way* earlier than ELF. Are you sure you're testing the right thing?

Ah, I must have mistakenly thought that other tools were already using llvm-readelf in cfe. Sorry about this.

This is in fact intended. The interface stubs feature needs to be verified against the actual symbols that are emitted into the elf binary. In the cases where I use llvm-readelf, I am using it to determine if the symbol is visible (to nm for example) but marked hidden in the .o file (but will end up being hidden in when linked).

Currently clang -emit-interface-stubs is not using any elf libraries, but it needs to verify against llvm-nm and/or llvm-readelf in these lit tests to determine if the visibility of the symbols generated in the text stubs is correct.

jfb added a comment.Jul 1 2019, 3:10 PM
In D60974#1565527, @jfb wrote:
In D60974#1565517, @jfb wrote:

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

Please don't do this. Your commit is wrong, and the right action from you is to revert it or fix it. I've fixed it for you here: rL364855

I'm also really not sure this is any good: why does clang look at ELF? In general I'd expect you to test something *way* earlier than ELF. Are you sure you're testing the right thing?

Ah, I must have mistakenly thought that other tools were already using llvm-readelf in cfe. Sorry about this.

This is in fact intended. The interface stubs feature needs to be verified against the actual symbols that are emitted into the elf binary. In the cases where I use llvm-readelf, I am using it to determine if the symbol is visible (to nm for example) but marked hidden in the .o file (but will end up being hidden in when linked).

Currently clang -emit-interface-stubs is not using any elf libraries, but it needs to verify against llvm-nm and/or llvm-readelf in these lit tests to determine if the visibility of the symbols generated in the text stubs is correct.

llvm-nm is already in the list of requirement for clang, so that would be fine to use. I'm not sure llvm-readelf is necessarily built for all targets, so my "fix" might still be broken. It's also another dependency, and a weird one at that. Can you test the property you're looking for in IR directly? And then test, in LLVM, that the same IR generates the ELF binary you want?

plotfi added a comment.Jul 1 2019, 3:13 PM
In D60974#1565544, @jfb wrote:
In D60974#1565527, @jfb wrote:
In D60974#1565517, @jfb wrote:

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

Please don't do this. Your commit is wrong, and the right action from you is to revert it or fix it. I've fixed it for you here: rL364855

I'm also really not sure this is any good: why does clang look at ELF? In general I'd expect you to test something *way* earlier than ELF. Are you sure you're testing the right thing?

Ah, I must have mistakenly thought that other tools were already using llvm-readelf in cfe. Sorry about this.

This is in fact intended. The interface stubs feature needs to be verified against the actual symbols that are emitted into the elf binary. In the cases where I use llvm-readelf, I am using it to determine if the symbol is visible (to nm for example) but marked hidden in the .o file (but will end up being hidden in when linked).

Currently clang -emit-interface-stubs is not using any elf libraries, but it needs to verify against llvm-nm and/or llvm-readelf in these lit tests to determine if the visibility of the symbols generated in the text stubs is correct.

llvm-nm is already in the list of requirement for clang, so that would be fine to use. I'm not sure llvm-readelf is necessarily built for all targets, so my "fix" might still be broken. It's also another dependency, and a weird one at that. Can you test the property you're looking for in IR directly? And then test, in LLVM, that the same IR generates the ELF binary you want?

I am currently working on the next part of clang interface stubs that will take the interface stubs per compilation unit and merge them into one text stub (which will be used by something like llvm-elfabi to generate a stubbed out ELF .so file). I was using llvm-nm, but there are cases where the symbol is present in the .o file but it is marked as HIDDEN and llvm-readelf was what I was using to determine if the symbol was in fact marked as hidden. In these cases, the linker will not emit the symbol in the final .so file but it still needs the symbol as part of linking.

plotfi added a comment.Jul 1 2019, 3:15 PM

@ymandel @jfb Thanks for reaching out on this. Apologies for missing this one.

plotfi added a comment.Jul 1 2019, 3:18 PM
In D60974#1565544, @jfb wrote:
In D60974#1565527, @jfb wrote:
In D60974#1565517, @jfb wrote:

So I think I know what may be going on on your end. The llvm-readelf in your path I believe might be the wrong lllvm-readelf (llvm-readelf-7). Are you sure you built llvm-readelf from git?

Please don't do this. Your commit is wrong, and the right action from you is to revert it or fix it. I've fixed it for you here: rL364855

I'm also really not sure this is any good: why does clang look at ELF? In general I'd expect you to test something *way* earlier than ELF. Are you sure you're testing the right thing?

Ah, I must have mistakenly thought that other tools were already using llvm-readelf in cfe. Sorry about this.

This is in fact intended. The interface stubs feature needs to be verified against the actual symbols that are emitted into the elf binary. In the cases where I use llvm-readelf, I am using it to determine if the symbol is visible (to nm for example) but marked hidden in the .o file (but will end up being hidden in when linked).

Currently clang -emit-interface-stubs is not using any elf libraries, but it needs to verify against llvm-nm and/or llvm-readelf in these lit tests to determine if the visibility of the symbols generated in the text stubs is correct.

llvm-nm is already in the list of requirement for clang, so that would be fine to use. I'm not sure llvm-readelf is necessarily built for all targets, so my "fix" might still be broken. It's also another dependency, and a weird one at that. Can you test the property you're looking for in IR directly? And then test, in LLVM, that the same IR generates the ELF binary you want?

FWIW, It's possible that when I finish the merge job part of clang interface stubs I can remove this llvm-readelf test dependency because I can just check against llvm-nm that the merged text stub is correct.

bruno added a subscriber: bruno.Jul 1 2019, 3:24 PM

I am currently working on the next part of clang interface stubs that will take the interface stubs per compilation unit and merge them into one text stub (which will be used by something like llvm-elfabi to generate a stubbed out ELF .so file). I was using llvm-nm, but there are cases where the symbol is present in the .o file but it is marked as HIDDEN and llvm-readelf was what I was using to determine if the symbol was in fact marked as hidden. In these cases, the linker will not emit the symbol in the final .so file but it still needs the symbol as part of linking.

This is similar to using "llvm-bcanalyzer" to check for serialization stuff from clang. We can't guarantee that to be available and adding a dep here would be weird. One way to workaround that would be to have a %llvm-readelf thing in lit and not run tests if not available (which also makes it questionable if it's not always running, but better than nothing?). Another option is to add a small clang tool that dumps what you need to check.

jfb added a comment.Jul 1 2019, 3:26 PM

Looking at the code quickly, I'm not sure that this should be in clang itself. It sounds like a better fit for a clang-based tool, and not clang. Why does it need to be part of clang?

plotfi added a comment.EditedJul 1 2019, 3:33 PM
In D60974#1565577, @jfb wrote:

Looking at the code quickly, I'm not sure that this should be in clang itself. It sounds like a better fit for a clang-based tool, and not clang. Why does it need to be part of clang?

In D60974#1565577, @jfb wrote:

Looking at the code quickly, I'm not sure that this should be in clang itself. It sounds like a better fit for a clang-based tool, and not clang. Why does it need to be part of clang?

@jfb Having interface stubs generated by clang itself makes sense because we want to use the same clang invocation (with the addition of -emit-interface-stubs) to be what generates the stubs so that everything is fully consistent with what -fvisibility/__attribute__ visibility would have exposed in a normal non-stub build.

plotfi added a comment.Jul 1 2019, 3:35 PM

I am currently working on the next part of clang interface stubs that will take the interface stubs per compilation unit and merge them into one text stub (which will be used by something like llvm-elfabi to generate a stubbed out ELF .so file). I was using llvm-nm, but there are cases where the symbol is present in the .o file but it is marked as HIDDEN and llvm-readelf was what I was using to determine if the symbol was in fact marked as hidden. In these cases, the linker will not emit the symbol in the final .so file but it still needs the symbol as part of linking.

This is similar to using "llvm-bcanalyzer" to check for serialization stuff from clang. We can't guarantee that to be available and adding a dep here would be weird. One way to workaround that would be to have a %llvm-readelf thing in lit and not run tests if not available (which also makes it questionable if it's not always running, but better than nothing?). Another option is to add a small clang tool that dumps what you need to check.

I will take a look at this. Thanks @bruno

plotfi added a comment.Jul 1 2019, 3:45 PM
In D60974#1565577, @jfb wrote:

Looking at the code quickly, I'm not sure that this should be in clang itself. It sounds like a better fit for a clang-based tool, and not clang. Why does it need to be part of clang?

@jfb I think this could actually be refactored into a clang based tool come to think of it, but I am also looking at how to add some features to the driver so that it can support job pipelines that are different from the standard PP -> CC1 -> BE -> ASM -> LINK pipeline. I can work on a change once I sort out this pipeline work to move the interface generation into a clang tool so that instead of invoking clang -cc1 to generate the interfaces the clang driver invokes the new clang interface generation tool.

In D60974#1565577, @jfb wrote:

Looking at the code quickly, I'm not sure that this should be in clang itself. It sounds like a better fit for a clang-based tool, and not clang. Why does it need to be part of clang?

@jfb I think this could actually be refactored into a clang based tool come to think of it, but I am also looking at how to add some features to the driver so that it can support job pipelines that are different from the standard PP -> CC1 -> BE -> ASM -> LINK pipeline. I can work on a change once I sort out this pipeline work to move the interface generation into a clang tool so that instead of invoking clang -cc1 to generate the interfaces the clang driver invokes the new clang interface generation tool.

That sounds pretty good, thanks! Maybe someone like @ributzka / @arphaman / @Bigcheese have opinions on how to best do this.
Once you do this, can you also revert rL364855?

plotfi added a comment.Jul 1 2019, 4:05 PM
In D60974#1565632, @jfb wrote:
In D60974#1565577, @jfb wrote:

Looking at the code quickly, I'm not sure that this should be in clang itself. It sounds like a better fit for a clang-based tool, and not clang. Why does it need to be part of clang?

@jfb I think this could actually be refactored into a clang based tool come to think of it, but I am also looking at how to add some features to the driver so that it can support job pipelines that are different from the standard PP -> CC1 -> BE -> ASM -> LINK pipeline. I can work on a change once I sort out this pipeline work to move the interface generation into a clang tool so that instead of invoking clang -cc1 to generate the interfaces the clang driver invokes the new clang interface generation tool.

That sounds pretty good, thanks! Maybe someone like @ributzka / @arphaman / @Bigcheese have opinions on how to best do this.
Once you do this, can you also revert rL364855?

That is definitely possible, because then only the clang-tool that emits the interfaces needs to verify against llvm-readelf. The the driver invocation path can just test against the llvm-nm output of the final .so file. More collaboration and feedback on this project is very welcome.

Currently @compnerd and I have been discussing allowing for a more flexible compilation pipeline generation, where possibly instead of the standard PP -> CC -> BE -> ASM -> LNK we might have something like PP -> clang-ifsgen -> llvm-ifsmerge -> llvm-elfabi.