This is an archive of the discontinued LLVM Phabricator instance.

[clang][IFS] Driver pipeline change for clang-ifs: generate interface stubs after standard pipeline.
ClosedPublic

Authored by plotfi on Nov 14 2019, 2:18 PM.

Details

Summary

Up until now, clang interface stubs has replaced the standard PP -> C -> BE -> ASM -> LNK pipeline. With this change, it will happen in conjunction with it. So what when you build your code you will get an a.out or lib.so as well as an interface stub file.

TODO: add another test or two.

Diff Detail

Event Timeline

plotfi created this revision.Nov 14 2019, 2:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 14 2019, 2:18 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
plotfi updated this revision to Diff 229698.Nov 16 2019, 8:43 AM

Adding test, and some additional features in the driver.

plotfi updated this revision to Diff 229699.Nov 16 2019, 8:46 AM
plotfi marked an inline comment as done.
plotfi added inline comments.
clang/test/InterfaceStubs/driver-test2.c
7

I would use -shared here, but many of the bots don't support that. Trying to figure out what else to do.

compnerd added inline comments.Nov 16 2019, 4:43 PM
clang/lib/Driver/Driver.cpp
3493

The reference binding is odd. Why not just pass PhaseList?

3500

Do you use the PhaseList again? Why not erase_if?

3506

structured bindings ... so much.

3508

A comment explaining that we cannot inspect assembly yet and why ifs don't make sense would be nice

3515

auto would be fine too

clang/lib/Driver/ToolChains/InterfaceStubs.cpp
34

IIRC, llvm::sys::path::replace_ext or stem should do this?

45

llvm::sys::fs::replace_ext

plotfi updated this revision to Diff 229731.Nov 17 2019, 2:35 PM
plotfi marked 7 inline comments as done.
plotfi marked an inline comment as done.
plotfi added inline comments.
clang/lib/Driver/Driver.cpp
3500

We tried this in getCompilationPhases. It didn't work very well.

3506

I don't understand?

compnerd added inline comments.Nov 17 2019, 3:30 PM
clang/lib/Driver/Driver.cpp
3506

C++17's structured bindings would be nice:

for (const auto &[Type, Arg] : Inputs)
3536

I think that switching on the Phase will make this more clear.

plotfi updated this revision to Diff 229745.Nov 17 2019, 10:03 PM
plotfi marked 2 inline comments as done.
plotfi updated this revision to Diff 229747.Nov 17 2019, 10:12 PM
plotfi marked an inline comment as done.
compnerd accepted this revision.Nov 18 2019, 2:31 PM
compnerd added inline comments.
clang/lib/Driver/Driver.cpp
3491

Extraneous whitespace

clang/lib/Driver/ToolChains/InterfaceStubs.cpp
37

Is there a way to check if the extension is a shared library extension, or better yet, check for the output type

clang/test/InterfaceStubs/driver-test.c
4

Unnecessary whitespace change

This revision is now accepted and ready to land.Nov 18 2019, 2:31 PM
plotfi updated this revision to Diff 229973.Nov 18 2019, 10:13 PM
plotfi marked 3 inline comments as done.
This revision was automatically updated to reflect the committed changes.
plotfi updated this revision to Diff 229986.Nov 19 2019, 12:27 AM

Hi! I think this patch might be causing some test failures on our mac bots:

FAIL: Clang :: InterfaceStubs/merge-conflict-test.c (6268 of 16220)
******************** TEST 'Clang :: InterfaceStubs/merge-conflict-test.c' FAILED ********************
Script:
--
: 'RUN: at line 1';   not /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/clang -fvisibility=default -o libfoo.so -emit-interface-stubs /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/driver-test.c 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c
--
Exit Code: 1

Command Output (stderr):
--
/b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c:2:11: error: CHECK: expected string not found in input
// CHECK: error: Interface Stub: Type Mismatch
          ^
<stdin>:1:1: note: scanning from here
clang-10: error: cannot specify -o when generating multiple output files
^
<stdin>:1:11: note: possible intended match here
clang-10: error: cannot specify -o when generating multiple output files
          ^

--

********************
Testing:  0.. 10.. 20.. 30..
FAIL: Clang :: InterfaceStubs/object-float.c (6276 of 16220)
******************** TEST 'Clang :: InterfaceStubs/object-float.c' FAILED ********************
Script:
--
: 'RUN: at line 1';   not /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/clang -fvisibility=default -o - -emit-interface-stubs /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object.c 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c
--
Exit Code: 1

Command Output (stderr):
--
/b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c:2:11: error: CHECK: expected string not found in input
// CHECK: error: Interface Stub: Size Mismatch
          ^
<stdin>:1:1: note: scanning from here
clang-10: error: cannot specify -o when generating multiple output files
^
<stdin>:1:11: note: possible intended match here
clang-10: error: cannot specify -o when generating multiple output files
          ^

--

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

Testing Time: 131.42s
********************
Failing Tests (2):
    Clang :: InterfaceStubs/merge-conflict-test.c
    Clang :: InterfaceStubs/object-float.c

Could you look into it? Thanks.

Bot link: https://ci.chromium.org/p/fuchsia/builders/ci/clang-mac-x64/b8896234755488932160

Looking into it. This change also affected Green Dragon. Thanks for the heads up.

Hi! I think this patch might be causing some test failures on our mac bots:

FAIL: Clang :: InterfaceStubs/merge-conflict-test.c (6268 of 16220)
******************** TEST 'Clang :: InterfaceStubs/merge-conflict-test.c' FAILED ********************
Script:
--
: 'RUN: at line 1';   not /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/clang -fvisibility=default -o libfoo.so -emit-interface-stubs /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/driver-test.c 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c
--
Exit Code: 1

Command Output (stderr):
--
/b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c:2:11: error: CHECK: expected string not found in input
// CHECK: error: Interface Stub: Type Mismatch
          ^
<stdin>:1:1: note: scanning from here
clang-10: error: cannot specify -o when generating multiple output files
^
<stdin>:1:11: note: possible intended match here
clang-10: error: cannot specify -o when generating multiple output files
          ^

--

********************
Testing:  0.. 10.. 20.. 30..
FAIL: Clang :: InterfaceStubs/object-float.c (6276 of 16220)
******************** TEST 'Clang :: InterfaceStubs/object-float.c' FAILED ********************
Script:
--
: 'RUN: at line 1';   not /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/clang -fvisibility=default -o - -emit-interface-stubs /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object.c 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c
--
Exit Code: 1

Command Output (stderr):
--
/b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c:2:11: error: CHECK: expected string not found in input
// CHECK: error: Interface Stub: Size Mismatch
          ^
<stdin>:1:1: note: scanning from here
clang-10: error: cannot specify -o when generating multiple output files
^
<stdin>:1:11: note: possible intended match here
clang-10: error: cannot specify -o when generating multiple output files
          ^

--

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

Testing Time: 131.42s
********************
Failing Tests (2):
    Clang :: InterfaceStubs/merge-conflict-test.c
    Clang :: InterfaceStubs/object-float.c

Could you look into it? Thanks.

Bot link: https://ci.chromium.org/p/fuchsia/builders/ci/clang-mac-x64/b8896234755488932160

I have a fix. About to push.

Hi! I think this patch might be causing some test failures on our mac bots:

FAIL: Clang :: InterfaceStubs/merge-conflict-test.c (6268 of 16220)
******************** TEST 'Clang :: InterfaceStubs/merge-conflict-test.c' FAILED ********************
Script:
--
: 'RUN: at line 1';   not /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/clang -fvisibility=default -o libfoo.so -emit-interface-stubs /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/driver-test.c 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c
--
Exit Code: 1

Command Output (stderr):
--
/b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/merge-conflict-test.c:2:11: error: CHECK: expected string not found in input
// CHECK: error: Interface Stub: Type Mismatch
          ^
<stdin>:1:1: note: scanning from here
clang-10: error: cannot specify -o when generating multiple output files
^
<stdin>:1:11: note: possible intended match here
clang-10: error: cannot specify -o when generating multiple output files
          ^

--

********************
Testing:  0.. 10.. 20.. 30..
FAIL: Clang :: InterfaceStubs/object-float.c (6276 of 16220)
******************** TEST 'Clang :: InterfaceStubs/object-float.c' FAILED ********************
Script:
--
: 'RUN: at line 1';   not /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/clang -fvisibility=default -o - -emit-interface-stubs /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object.c 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangKJGdzA/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c
--
Exit Code: 1

Command Output (stderr):
--
/b/s/w/ir/k/llvm-project/clang/test/InterfaceStubs/object-float.c:2:11: error: CHECK: expected string not found in input
// CHECK: error: Interface Stub: Size Mismatch
          ^
<stdin>:1:1: note: scanning from here
clang-10: error: cannot specify -o when generating multiple output files
^
<stdin>:1:11: note: possible intended match here
clang-10: error: cannot specify -o when generating multiple output files
          ^

--

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

Testing Time: 131.42s
********************
Failing Tests (2):
    Clang :: InterfaceStubs/merge-conflict-test.c
    Clang :: InterfaceStubs/object-float.c

Could you look into it? Thanks.

Bot link: https://ci.chromium.org/p/fuchsia/builders/ci/clang-mac-x64/b8896234755488932160