This is an archive of the discontinued LLVM Phabricator instance.

Clang IFSO driver action.
ClosedPublic

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

Diff Detail

Repository
rC Clang

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
compnerd added inline comments.May 7 2019, 8:53 AM
clang/lib/Frontend/FrontendActions.cpp
181

I'm not sure I like this very much. You are templating over a type a function that needs to walk the hierarchy for NamedDecl. This is going to re-emit the function and without LTO cause a large .text contribution for something that should really just be a jump table. Would it not be possible to use a covered switch on the kindof() in the NamedDecl. The covering should ensure that future changes would allow us to find this site.

188

I understand this, but, it may be nice to have a comment explaining why we only consider default visibility (hidden visibility interfaces cannot be seen by consumers, and protected mode visibility in ELF does not participate in linking, only loading).

196

Newline before this would be nice.

198

This is confusing, can you rewrite this as, dropping L204-205:

uint8_t Type = isa<VarDecl>(ND) ? llvm::ELF::STT_OBJECT : llvm::ELF::STT_FUNC;
202

Again, I think that this is slightly confusing, and would prefer a ternary.

206

Can you not use a universal initialiser? In the case you cannot, std::make_pair would be nicer to use for the type deduction.

213

debugging left over?

218

Similar to the previous case, I am slightly worried about the size contributions here. Why not a covered switch?

221

const auto *D?

This also makes very little sense to the casual reader. This cast is very confusing. There is no reason to assume that an arbitrary NamedDecl is a DeclContext. It is only made even more confusing by the fact that the decl that is retrieved is a pointer - since that is an implementation detail of the decl_iterator in the decl_range returned by decls which is implicitly dereferenced by the range based for loop. Making the type explicit by the means of the covered switch and an explicit cast to the DeclContext should help in clearing that up.

222

Hmm, do we have a guarantee that the decl is named? Could you not hit a _Static_assert or static_assert in this traversal? Or if it is a C++ context, an extern "C" block? What about #pragma comment(...)? Please add test cases for these.

226

Again, the templating here worries me.

231

Hmm, what guarantee do we have that the templated type is a template type?

253

Please put this in an LLVM_DEBUG.

268

const? I think that this might be easier to parse for the reader as:

if (const auto *FD = dyn_cast<FunctionDecl>(ND))
  if (FD->isLateTemplateParsed())
    return LateParsedDecls.insert(FD).first != LateParsedDecls.end();
  else
    return NamedDecls.insert(FD).first != NamedDecls.end();

if (const auto *VD = dyn_cast<ValueDecl>(ND))
  return ValueDecls.insert(VD).first != ValueDecls.end();

return NamedDecls.insert(ND) != NamedDecls.end();
291

S is the traditional initialism.

296

Typo of ||? The field is boolean not a mask.

340

const auto &E? I wish that we had structured decomposition already.

plotfi marked 6 inline comments as done.May 7 2019, 9:06 AM
plotfi added inline comments.
clang/include/clang/Driver/Options.td
626

Oh, I was specifying experimental in the -interface-stubs-version=experimental-ifo-elf-v1. Do you want the main flag to also be -emit-interface-stubs-experimental??

clang/include/clang/Driver/Types.def
91

I went with ifs because ifo implies the analog of a .o file and ifso implies the analog of a .so file. I want the tbe/ifs text files to just be thought of as something a little different. Like symbol listings that another tool can assemble into whatever format.

clang/lib/Frontend/CompilerInvocation.cpp
1648

I think that makes sense.

clang/lib/Frontend/FrontendActions.cpp
178

Can we do data-structure improvements post landing the first version?

213

Ah yeah I need to replace this with an llvm_unreachable or something.

296

It is a bitmask.

compnerd added inline comments.May 7 2019, 9:12 AM
clang/include/clang/Driver/Options.td
626

Okay, I can live with that. I guess that was just unclear to me. Doing that is nicer in that there is less churn in the actual flags.

clang/include/clang/Driver/Types.def
91

Oh, I see. Yeah .... torn on that tbh. There are aspects of it as being analogs to .o or .obj as well. But, having them be confused for one another is worse. If this makes sense to you and @rupprecht, WFM.

clang/lib/Frontend/FrontendActions.cpp
296

Oh!

plotfi marked 2 inline comments as done.May 9 2019, 8:13 AM
plotfi marked 2 inline comments as done.
plotfi marked 2 inline comments as done.May 9 2019, 8:22 AM
plotfi added inline comments.
clang/lib/Driver/ToolChains/Clang.cpp
3590

Couldn't I do this in the cc1 path?

plotfi marked 2 inline comments as done.May 9 2019, 1:22 PM
plotfi marked 2 inline comments as done.May 9 2019, 1:44 PM
plotfi added inline comments.
clang/lib/Frontend/FrontendActions.cpp
222

HandleNamedDecl bails when the NamedDecl is not a NamedDecl.

plotfi marked 2 inline comments as done.May 9 2019, 1:53 PM
plotfi updated this revision to Diff 198902.May 9 2019, 2:02 PM

addressing a lot of @compnerd 's feedback. Still lots of templating.

plotfi marked 8 inline comments as done.May 9 2019, 2:04 PM
plotfi updated this revision to Diff 198963.May 9 2019, 5:49 PM
plotfi marked 9 inline comments as done.

removed all the template functions to handle decls.

plotfi marked 7 inline comments as done.May 9 2019, 5:52 PM
plotfi updated this revision to Diff 198967.May 9 2019, 6:20 PM

cleaned up VisitNamedDecl

plotfi marked an inline comment as done.May 9 2019, 6:22 PM
plotfi updated this revision to Diff 198977.May 9 2019, 8:17 PM

renaming things from "ifso" to "interface stubs"

plotfi marked an inline comment as done.May 9 2019, 9:38 PM
plotfi added inline comments.
llvm/lib/TextAPI/ELF/TBEHandler.cpp
137 ↗(On Diff #198977)

@jakehehrlich Here, I've added an Endian field to tbe. I think I can just generate the tbe that llvm-elfabi consumes. The experimental yaml output is more for debugging. Tell me what you think.

@jakehehrlich What else are you looking for here? Can the patch for merging tbe files come later? @compnerd @rupprecht thoughts? I think this is a reasonable compromise: a minimal subset of what the yaml2obj and llvm-elfabi (with the addition of the Endian field) tools can already consume.

This shouldn't emit the .tbe format at all, the .tbe format is meant to be in near 1-1 correspondence with .so files, not with .o files. It has things like DT_NEEDED, and DT_SONAME related information that don't make sense for .o files for instance.

If we put things under an --experimental flags, minimize what we add in the first patch, and try and make each additional field added need based, I'm ok with whatever being added to Clang assuming it doesn't interfere with other parts of the compiler.

llvm/include/llvm/TextAPI/ELF/ELFStub.h
58 ↗(On Diff #198977)

Why do we need or want this? If it is needed can it be added later when needed? Also why is this a string?

plotfi marked 2 inline comments as done.May 10 2019, 11:58 AM
plotfi added inline comments.
llvm/include/llvm/TextAPI/ELF/ELFStub.h
58 ↗(On Diff #198977)

Just a suggestion, I saw that ELF needs endianness specified and I also saw that the llvm-elfabi tool (the latest patch set from phab anyways) has cmd clangs for specifying endianness and thought it could be nice to specify in the file. Also you are right, this probably shouldn't be a string. I can drop it from this change.

plotfi marked an inline comment as done.May 10 2019, 12:10 PM

This shouldn't emit the .tbe format at all, the .tbe format is meant to be in near 1-1 correspondence with .so files, not with .o files. It has things like DT_NEEDED, and DT_SONAME related information that don't make sense for .o files for instance.

If we put things under an --experimental flags, minimize what we add in the first patch, and try and make each additional field added need based, I'm ok with whatever being added to Clang assuming it doesn't interfere with other parts of the compiler.

That sounds good. I wasn't sure if you wanted straight up tbe or not. I can basically keep what we have here and make the heading line include an "experimental" tag so that it cant be directly read by the llvm-elfabi tool without some changes. I do think it should be sufficient to have some subset of tbe as a merging format in llvm-elbabi. Will post an update.

plotfi updated this revision to Diff 199058.May 10 2019, 12:43 PM

Changing !tapi-tbe to !experimental-tapi-elf-v1, removing Endianness field from tapi-tbe.

This shouldn't emit the .tbe format at all, the .tbe format is meant to be in near 1-1 correspondence with .so files, not with .o files. It has things like DT_NEEDED, and DT_SONAME related information that don't make sense for .o files for instance.

If we put things under an --experimental flags, minimize what we add in the first patch, and try and make each additional field added need based, I'm ok with whatever being added to Clang assuming it doesn't interfere with other parts of the compiler.

So my latest diff addresses this. The schema resembles the tbe format but it is marked with experimental and will not load with the current llvm-elfabi tool. Should generate something resembling:

--- !experimental-tapi-elf-v1
Arch: x86_64
Symbols:
  __Z16foo_default_visiii: { Type: Func }
  __Z6fvih_1ii: { Type: Func }
  __ZZ4fvihvE8fortytwo: { Type: Object, Size: 4 }
  __Z12someWeakFuncv: { Type: Func, Weak: true }
...

How does this look to you?

This really needs more tests. Please add a positive/negative test for the driver argument. Please try to organise the tests a bit to show what it is that they are testing, emission of public functions, not of protected functions or hidden functions. Behaviour with C++ classes. Behaviour with templates. I don't see any test for the vtable for classes that are public/private.

This really needs more tests. Please add a positive/negative test for the driver argument. Please try to organise the tests a bit to show what it is that they are testing, emission of public functions, not of protected functions or hidden functions. Behaviour with C++ classes. Behaviour with templates. I don't see any test for the vtable for classes that are public/private.

Agreed. Adding.

plotfi updated this revision to Diff 199112.May 10 2019, 5:20 PM

Adding lit test cases.

@compnerd Any other test cases you'd like before the first drop? @jakehehrlich @rupprecht Do things here look good to you guys? Both formats are marked experimental, I plan to work on a merge action next.

How about some cases for:

  • global variable which is static and extern'ed
  • global variable which is static defined in a function which is static
  • global variable which is static defined in a function which is *not* inline
  • global variable which is static which is static inline (GNU inline semantics)
  • global variable which is static which is static inline (C99 inline semantics)
  • virtual functions
  • class vtables
  • tests for hidden class deriving from hidden class
  • tests for hidden class deriving from public class
  • tests for public class deriving from public class
  • tests for public class deriving from hidden class
  • constexpr cases
plotfi updated this revision to Diff 200393.May 20 2019, 8:33 PM

adding a nice inline test

plotfi updated this revision to Diff 200602.May 21 2019, 3:50 PM

fixing support for static functions.

plotfi updated this revision to Diff 200805.May 22 2019, 11:56 AM

adding static/extern tests.

plotfi updated this revision to Diff 200828.May 22 2019, 3:24 PM
plotfi updated this revision to Diff 201104.May 23 2019, 5:22 PM

Improving visibility extraction for class template specializations.

plotfi updated this revision to Diff 201339.May 24 2019, 2:38 PM

More test improvement.

plotfi updated this revision to Diff 201471.May 26 2019, 3:41 PM

virtual function test

clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
30 ↗(On Diff #201471)

would be nice to have a newline before the ctor

plotfi updated this revision to Diff 202976.Jun 4 2019, 10:18 AM

Adding a test for inheritance and constructors/destroctors. Also addressing feedback from @alexshap

plotfi marked an inline comment as done.Jun 4 2019, 10:18 AM
plotfi updated this revision to Diff 203464.Jun 6 2019, 4:23 PM

Updated hidden parent/child class inheritance cases.

plotfi updated this revision to Diff 203465.Jun 6 2019, 4:26 PM

git mv'ed hidden-class-inheritance.cpp

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

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

Args.getLastArgValue(options::OPT_iterface_stub_version_EQ) should already default to returning the empty string if unset (note the default param)

clang/lib/Frontend/CompilerInvocation.cpp
1678–1680

(same here)

1688

I think this is very much reachable if someone provides --interface-stub-version=x

clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
20–21 ↗(On Diff #203465)

nit: these default initializations are redundant

26 ↗(On Diff #203465)

ditto

39–41 ↗(On Diff #203465)

Can you add a comment why these two are excluded?

41 ↗(On Diff #203465)

llvm::is_contained(Symbols, ND)

44–47 ↗(On Diff #203465)

This would be terser (and more readable) combined; if (isa<FieldDecl>(ND) || isa<ParamValDecl>(ND))

95 ↗(On Diff #203465)

auto -> std::vector<std::string>, unless the return type is obvious to anyone that commits here (i.e. not me)

107 ↗(On Diff #203465)

auto -> std::string

206–207 ↗(On Diff #203465)

This should be an error, not llvm_unreachable (which I think gets filtered out in release builds)

rupprecht added inline comments.Jun 7 2019, 1:27 PM
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
242 ↗(On Diff #203465)

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
41 ↗(On Diff #203465)

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
1659

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

clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
21 ↗(On Diff #204308)

An enumeration may be nicer.

39 ↗(On Diff #204308)

I tend to prefer if (RDO & ~FromTU)

56 ↗(On Diff #204308)

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

65 ↗(On Diff #204308)

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

68 ↗(On Diff #204308)

A newline before this would be nice.

72 ↗(On Diff #204308)

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;
73 ↗(On Diff #204308)

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.

77 ↗(On Diff #204308)

I think that flipping this around would be nicer.

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

return FD->isInlined() && !Instance.getLangOpts().GNUInline;
79 ↗(On Diff #204308)

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

118 ↗(On Diff #204308)

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.

150 ↗(On Diff #204308)

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
21 ↗(On Diff #204308)

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.

39 ↗(On Diff #204308)

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

I'm not sure if these are logically equivalent

72 ↗(On Diff #204308)

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

77 ↗(On Diff #204308)

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
91 ↗(On Diff #204978)

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.

116 ↗(On Diff #204978)

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.