Discussion:
libport usage and extra inclusion line
Menno Valkema
2016-06-21 11:01:55 UTC
Permalink
Hi Everyone,

We're using several libraries in our product, and most of them just work
by adding a line like:

LIBS = libc

However in some cases this is not sufficient. For example lwip requires
an additional include directive:

INC_DIR += $(REP_DIR)/src/lib/lwip/include
(line from repos/libports/src/test/lwip/http_srv_static/target.mk)

Leaving out this line will result in a compilation error of a local
include file. Looking at various library ports (mbedtls, polarssl, curl,
and probably more) we see similar behavior. Usually some library
configuration header file should be added manually to the include path
to make things work.

Adding this extra line for a default library configuration feels
redundant, so we're wondering we might do something we're not supposed
to do, or should be done in a different way?

Thanks, Menno
--
Cyber Security Labs B.V. | Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
Christian Helmuth
2016-06-21 12:10:13 UTC
Permalink
Hello Menno,
Post by Menno Valkema
However in some cases this is not sufficient. For example lwip requires
INC_DIR += $(REP_DIR)/src/lib/lwip/include
(line from repos/libports/src/test/lwip/http_srv_static/target.mk)
If I remove this line from target.mk the test component compiles
without error.
Post by Menno Valkema
Leaving out this line will result in a compilation error of a local
include file. Looking at various library ports (mbedtls, polarssl, curl,
and probably more) we see similar behavior. Usually some library
configuration header file should be added manually to the include path
to make things work.
Could you please be more specific about the error message or maybe
point out an example in the public sources that breaks if the INC_DIR
directive is removed?

Regards
--
Christian Helmuth
Genode Labs

http://www.genode-labs.com/ · http://genode.org/
https://twitter.com/GenodeLabs · /ˈdʒiː.nəʊd/

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
Menno Valkema
2016-06-22 08:39:38 UTC
Permalink
Hello Christian,

Thanks for your reply. A better example is the curl library. I've put
together an example to reproduce the behavior.

Attached a patch which includes the curl library into the hello
tutorial. It doesn't call any methods of the library, but it does
include <curl/curl.h> and shows the necessity of the extra INC_DIR
directive.

To run it I take the following steps:
$ git clone https://github.com/genodelabs/genode.git hello_curl
$ cd hello_curl

Patch the sources with the attached hello_curl.patch
$ patch -p1 < ~/tmp/hello_curl.patch
$ ./tool/create_builddir linux_x86
$ cd build/linux_x86
$ echo 'REPOSITORIES += $(GENODE_DIR)/repos/hello_tutorial' >> \
etc/build.conf
$ echo 'REPOSITORIES += $(GENODE_DIR)/repos/libports' >> etc/build.conf
$ ../../tool/ports/prepare_port curl libc libssh openssl zlib
$ make run/hello

This compiles and runs fine (not doing anything functional).

Now remove the following line from
repos/hello_tutorial/src/hello/client/target.mk:

INC_DIR += $(REP_DIR)/../libports/src/lib/curl/spec/64bit/curl/

Running it again will give you an error about a missing "curlbuild.h".
Hence our question what are we doing wrong? Is this behavior by design,
or should we take different steps to include and use the library port?

Thanks, Menno

PS. I've tested lwip in a similar way, and you're right: the error is
not there.
--
Cyber Security Labs B.V. | https://nlcsl.com
Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
Post by Christian Helmuth
Hello Menno,
Post by Menno Valkema
However in some cases this is not sufficient. For example lwip requires
INC_DIR += $(REP_DIR)/src/lib/lwip/include
(line from repos/libports/src/test/lwip/http_srv_static/target.mk)
If I remove this line from target.mk the test component compiles
without error.
Post by Menno Valkema
Leaving out this line will result in a compilation error of a local
include file. Looking at various library ports (mbedtls, polarssl, curl,
and probably more) we see similar behavior. Usually some library
configuration header file should be added manually to the include path
to make things work.
Could you please be more specific about the error message or maybe
point out an example in the public sources that breaks if the INC_DIR
directive is removed?
Regards
Emery Hemingway
2016-06-22 09:10:41 UTC
Permalink
I think I had the same issue with curl, I just filed an issue about this:
https://github.com/genodelabs/genode/issues/2021

Emery
Post by Menno Valkema
Hello Christian,
Thanks for your reply. A better example is the curl library. I've put
together an example to reproduce the behavior.
Attached a patch which includes the curl library into the hello
tutorial. It doesn't call any methods of the library, but it does
include <curl/curl.h> and shows the necessity of the extra INC_DIR
directive.
$ git clone https://github.com/genodelabs/genode.git hello_curl
$ cd hello_curl
Patch the sources with the attached hello_curl.patch
$ patch -p1 < ~/tmp/hello_curl.patch
$ ./tool/create_builddir linux_x86
$ cd build/linux_x86
$ echo 'REPOSITORIES += $(GENODE_DIR)/repos/hello_tutorial' >> \
etc/build.conf
$ echo 'REPOSITORIES += $(GENODE_DIR)/repos/libports' >> etc/build.conf
$ ../../tool/ports/prepare_port curl libc libssh openssl zlib
$ make run/hello
This compiles and runs fine (not doing anything functional).
Now remove the following line from
INC_DIR += $(REP_DIR)/../libports/src/lib/curl/spec/64bit/curl/
Running it again will give you an error about a missing "curlbuild.h".
Hence our question what are we doing wrong? Is this behavior by design,
or should we take different steps to include and use the library port?
Thanks, Menno
PS. I've tested lwip in a similar way, and you're right: the error is
not there.
--
Cyber Security Labs B.V. | https://nlcsl.com
Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
Post by Christian Helmuth
Hello Menno,
Post by Menno Valkema
However in some cases this is not sufficient. For example lwip requires
INC_DIR += $(REP_DIR)/src/lib/lwip/include
(line from repos/libports/src/test/lwip/http_srv_static/target.mk)
If I remove this line from target.mk the test component compiles
without error.
Post by Menno Valkema
Leaving out this line will result in a compilation error of a local
include file. Looking at various library ports (mbedtls, polarssl, curl,
and probably more) we see similar behavior. Usually some library
configuration header file should be added manually to the include path
to make things work.
Could you please be more specific about the error message or maybe
point out an example in the public sources that breaks if the INC_DIR
directive is removed?
Regards
diff --git a/repos/hello_tutorial/run/hello.run b/repos/hello_tutorial/run/hello.run
index 0dd52d8..9f017f0 100644
--- a/repos/hello_tutorial/run/hello.run
+++ b/repos/hello_tutorial/run/hello.run
@@ -14,6 +14,7 @@ install_config {
<config>
<parent-provides>
<service name="LOG"/>
+ <service name="ROM"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
@@ -31,7 +32,8 @@ install_config {
# Boot image
#
-build_boot_image { core init hello_client hello_server }
+build_boot_image { core init hello_client hello_server
+ curl.lib.so ld.lib.so libc.lib.so libcrypto.lib.so libssh.lib.so libssl.lib.so zlib.lib.so }
append qemu_args " -nographic "
diff --git a/repos/hello_tutorial/src/hello/client/main.cc b/repos/hello_tutorial/src/hello/client/main.cc
index f600117..19bc1e4 100644
--- a/repos/hello_tutorial/src/hello/client/main.cc
+++ b/repos/hello_tutorial/src/hello/client/main.cc
@@ -16,6 +16,7 @@
#include <base/log.h>
#include <hello_session/connection.h>
+#include <curl/curl.h>
Genode::size_t Component::stack_size() { return 64*1024; }
diff --git a/repos/hello_tutorial/src/hello/client/target.mk b/repos/hello_tutorial/src/hello/client/target.mk
index 3d69e29..7987979 100644
--- a/repos/hello_tutorial/src/hello/client/target.mk
+++ b/repos/hello_tutorial/src/hello/client/target.mk
@@ -1,3 +1,4 @@
TARGET = hello_client
SRC_CC = main.cc
-LIBS = base
+LIBS = base curl libc
+INC_DIR += $(REP_DIR)/../libports/src/lib/curl/spec/64bit/curl/
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
Josef Söntgen
2016-06-22 09:12:34 UTC
Permalink
Hello Menno,
Post by Menno Valkema
Now remove the following line from
INC_DIR += $(REP_DIR)/../libports/src/lib/curl/spec/64bit/curl/
Running it again will give you an error about a missing "curlbuild.h".
Hence our question what are we doing wrong? Is this behavior by design,
or should we take different steps to include and use the library port?
The problem here is that the import file contains an incorrect include
path and is therefore not picked up by Genode's build system. Please see
the attached patch [1] for a fix.


Regards,
Josef
--
Josef Söntgen
Genode Labs

http://www.genode-labs.com/ · http://genode.org/
Menno Valkema
2016-06-22 10:19:59 UTC
Permalink
Hi Josef,

I've tested your patch and this solves the issue! Thanks.

Whenever we encounter similar behavior we'll report it or sent a fix for
the .mk files, and refrain from coming up with INC_DIR-based workarounds
in our own project ;-)

Cheers, Menno
--
Cyber Security Labs B.V. | https://nlcsl.com
Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
Post by Christian Helmuth
Hello Menno,
Post by Menno Valkema
Now remove the following line from
INC_DIR += $(REP_DIR)/../libports/src/lib/curl/spec/64bit/curl/
Running it again will give you an error about a missing "curlbuild.h".
Hence our question what are we doing wrong? Is this behavior by design,
or should we take different steps to include and use the library port?
The problem here is that the import file contains an incorrect include
path and is therefore not picked up by Genode's build system. Please see
the attached patch [1] for a fix.
Regards,
Josef
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
Loading...