Skip to content

Create pkg-config files from CMake#20211

Merged
jtattermusch merged 5 commits intogrpc:masterfrom
zackgalbreath:cmake-pkg-config
Oct 11, 2019
Merged

Create pkg-config files from CMake#20211
jtattermusch merged 5 commits intogrpc:masterfrom
zackgalbreath:cmake-pkg-config

Conversation

@zackgalbreath
Copy link
Copy Markdown
Contributor

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Sep 9, 2019

CLA Check
One or more committers are not authorized under a signed CLA as indicated below. Please click here to be authorized.

@jtattermusch
Copy link
Copy Markdown
Contributor

@zackgalbreath I started the tests. In the meantime, you'll need to sign the CLA.

@jtattermusch jtattermusch self-assigned this Sep 10, 2019
@jtattermusch jtattermusch added lang/c++ release notes: yes Indicates if PR needs to be in release notes labels Sep 10, 2019
@jtattermusch
Copy link
Copy Markdown
Contributor

It would also be nice to add some check for the .pc files being setup correctly to one of our distribtests so that this gets continously tested.

@jtattermusch
Copy link
Copy Markdown
Contributor

@zackgalbreath have you been able to figure out the CLA signing process?

@jtattermusch
Copy link
Copy Markdown
Contributor

@zackgalbreath can you please regenerate the CMakeLists.txt to resolve the merge conflict?

It would be good to expand our distribtests to make sure the generated .pc files are actually installed and that they work as expected.
The scripts being run by our distribtests are here: https://github.com/grpc/grpc/tree/master/test/distrib/cpp

-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-laddress_sorting\
-lcares\
-lz\
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As you can see, I had to add some libraries to the helloworld Makefile to get it to build. Please let me know if you would've expected this to build cleanly without these modifications.

Copy link
Copy Markdown
Contributor

@jtattermusch jtattermusch Oct 1, 2019

Choose a reason for hiding this comment

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

I think the reason for the difference it that when built and installed via Makefile, address_sorting, cares and zlib are statically linked into libgrpc (as far as I can tell)

With cmake installation (as per the distribtest), we're actually building each of these libraries with gRPC_*_PROVIDER=package, so they end up installed as individual libraries (and thus need to be linked explicitly).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That actually begs the question that if the deps are installed as separate libraries, perhaps the pkgconfig files should know about these dependencies? (which is kind of the point of pkgconfig).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Discussed with @nicolasnoble offline -
the pkg config files need to carry information about what the dependencies are (gpr, address_sorting, cares, zlib) for them to be useful - that should make the original helloworld Makefile to work fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 I updated the CMake and Makefile created .pc files to indicate these dependencies. I also updated Requires.private to Requires so pkg-config will find grpc for you if you ask for grpc++.

@jtattermusch
Copy link
Copy Markdown
Contributor

The EasyCLA check is looking good, glad that it finally worked for you!

@zackgalbreath
Copy link
Copy Markdown
Contributor Author

Are these four failing checks something I should look into?

@jtattermusch
Copy link
Copy Markdown
Contributor

jtattermusch commented Oct 9, 2019

tasks.distribtest.cpp_linux_x64_jessie_routeguide fails with
https://source.cloud.google.com/results/invocations/96da7424-2661-4830-be5a-536ef2842063/targets/github%2Fgrpc/tests

+ make
protoc -I ../../protos --cpp_out=. ../../protos/helloworld.proto
g++ -std=c++11 `pkg-config --cflags protobuf grpc`  -c -o helloworld.pb.o helloworld.pb.cc
protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/helloworld.proto
g++ -std=c++11 `pkg-config --cflags protobuf grpc`  -c -o helloworld.grpc.pb.o helloworld.grpc.pb.cc
g++ -std=c++11 `pkg-config --cflags protobuf grpc`  -c -o greeter_client.o greeter_client.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_client.o -L/usr/local/lib `pkg-config --libs protobuf grpc++` -pthread -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_client
/usr/bin/ld: cannot find -lcares
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
Makefile:44: recipe for target 'greeter_client' failed

The /usr/bin/ld: cannot find -lcares seems to be related to the Makefile changes in this PR

https://github.com/grpc/grpc/blob/master/test/distrib/cpp/run_distrib_test_routeguide.sh

@jtattermusch
Copy link
Copy Markdown
Contributor

The above error seems to be happening because our Makefile build actually links all the dependent libraries statically (e.g. cares, libz) as part of libgrpc, so e.g. -lcares should not be used for the pkgconfig files generated by the Makefile.

Change "Requires.private" to "Requires" so pkg-config can better provide gRPC's
dependencies.
Use pkg-config to automatically find grpc as a dependency of grpc++.
Copy link
Copy Markdown
Contributor

@jtattermusch jtattermusch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution!
I'll merge as soon once I doublecheck the test results.

@jtattermusch
Copy link
Copy Markdown
Contributor

Known failures:
#20519
#20472

@jtattermusch jtattermusch merged commit 3990d9c into grpc:master Oct 11, 2019
@nanahpang
Copy link
Copy Markdown
Contributor

@jtattermusch
Copy link
Copy Markdown
Contributor

@nanahpang
Copy link
Copy Markdown
Contributor

Yes, I have noticed that the failure happened when #20380 got merged. But the changes in #20380 doesn't modify pkg-config. Maybe that PR didn't sync with your changes. I will ask Mark to sync and rebuild that PR first.

@nicolasnoble
Copy link
Copy Markdown
Contributor

LGTM, btw.

@jtattermusch
Copy link
Copy Markdown
Contributor

@zackgalbreath it looks like we might be failing to reference openssl as one of the dependencies in the pkgconfig files. A seemingly unrelated PR is triggering the problem:
#20606 (comment)

https://source.cloud.google.com/results/invocations/a24056d4-44aa-439f-a253-dbf3163ab34d/targets/github%2Fgrpc/tests

@zackgalbreath zackgalbreath deleted the cmake-pkg-config branch December 12, 2019 18:53
@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lang/c++ release notes: yes Indicates if PR needs to be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmake: pkgconfig files not installed

5 participants