Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build libyang on FreeBSD #17

Closed
rastislavs opened this issue Feb 5, 2016 · 10 comments
Closed

Unable to build libyang on FreeBSD #17

rastislavs opened this issue Feb 5, 2016 · 10 comments
Assignees

Comments

@rastislavs
Copy link

$ cc -v
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.1
Thread model: posix

2 warnings generated.
[ 33%] Building C object CMakeFiles/yang.dir/src/parser_yin.c.o
[ 37%] Building C object CMakeFiles/yang.dir/src/parser_xml.c.o
[ 40%] Building C object CMakeFiles/yang.dir/src/parser_json.c.o
[ 44%] Building C object CMakeFiles/yang.dir/src/tree_schema.c.o
[ 48%] Building C object CMakeFiles/yang.dir/src/tree_data.c.o
/usr/home/rasto/lib/libyang/src/tree_data.c:360:5: warning: implicit declaration of function 'asprintf' is invalid in C99 [-Wimplicit-function-declaration]
asprintf(&xml, "<%s>%s</%s>", schema->name, (val_xml ? val_xml : ""), schema->name);
^
1 warning generated.
[ 51%] Building C object CMakeFiles/yang.dir/src/printer.c.o
[ 55%] Building C object CMakeFiles/yang.dir/src/xpath.c.o
/usr/home/rasto/lib/libyang/src/xpath.c:842:13: warning: implicit declaration of function 'asprintf' is invalid in C99 [-Wimplicit-function-declaration]
asprintf(&str_num, "%lld", (long long)set->value.num);
^
1 warning generated.
[ 59%] Building C object CMakeFiles/yang.dir/src/printer_yang.c.o
[ 62%] Building C object CMakeFiles/yang.dir/src/printer_xml.c.o
[ 66%] Building C object CMakeFiles/yang.dir/src/printer_tree.c.o
[ 70%] Building C object CMakeFiles/yang.dir/src/printer_info.c.o
[ 74%] Building C object CMakeFiles/yang.dir/src/printer_json.c.o
[ 77%] Building C object CMakeFiles/yang.dir/src/yang_types.c.o
[ 81%] Linking C shared library libyang.so
/usr/bin/ld: /usr/bin/../lib/libprofile_rt.a: No such file: No such file or directory
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[2]: stopped in /usr/home/rasto/lib/libyang/build
*** Error code 1

Stop.
make[1]: stopped in /usr/home/rasto/lib/libyang/build
*** Error code 1

Stop.
make: stopped in /usr/home/rasto/lib/libyang/build

rkrejci added a commit that referenced this issue Feb 5, 2016
Seems that the -coverage option is not very portable (#17), so move
it from DEBUG build in cmake into the Travis config file, since we
codecov from Travis.
@rastislavs
Copy link
Author

Sorry, my previous post was a bit misleading, the build has failed there due to missing libprofile, which is actually not needed for Release build. However, the build is still failing even in Release mode. This can be work-arounded with omitting build of lint (without it the build passes, but still with quite a lot of warnings). The full log from Release build:

$ make
[ 3%] Building C object CMakeFiles/yang.dir/src/common.c.o
[ 7%] Building C object CMakeFiles/yang.dir/src/context.c.o
/usr/home/rasto/lib/libyang/src/context.c:72:15: warning: implicit declaration of function 'get_current_dir_name' is invalid in C99 [-Wimplicit-function-declaration]
cwd = get_current_dir_name();
^
/usr/home/rasto/lib/libyang/src/context.c:72:13: warning: incompatible integer to pointer conversion assigning to 'char ' from 'int' [-Wint-conversion]
cwd = get_current_dir_name();
^ ~~~~~~~~~~~~~~~~~~~~~~
/usr/home/rasto/lib/libyang/src/context.c:80:33: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
ctx->models.search_path = get_current_dir_name();
^ ~~~~~~~~~~~~~~~~~~~~~~
/usr/home/rasto/lib/libyang/src/context.c:120:13: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
cwd = get_current_dir_name();
^ ~~~~~~~~~~~~~~~~~~~~~~
/usr/home/rasto/lib/libyang/src/context.c:128:33: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
ctx->models.search_path = get_current_dir_name();
^ ~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
[ 11%] Building C object CMakeFiles/yang.dir/src/log.c.o
[ 14%] Building C object CMakeFiles/yang.dir/src/dict.c.o
[ 18%] Building C object CMakeFiles/yang.dir/src/resolve.c.o
[ 22%] Building C object CMakeFiles/yang.dir/src/validation.c.o
[ 25%] Building C object CMakeFiles/yang.dir/src/xml.c.o
[ 29%] Building C object CMakeFiles/yang.dir/src/parser.c.o
/usr/home/rasto/lib/libyang/src/parser.c:147:16: warning: implicit declaration of function 'get_current_dir_name' is invalid in C99 [-Wimplicit-function-declaration]
cwd = wd = get_current_dir_name();
^
/usr/home/rasto/lib/libyang/src/parser.c:147:14: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
cwd = wd = get_current_dir_name();
^ ~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
[ 33%] Building C object CMakeFiles/yang.dir/src/parser_yin.c.o
[ 37%] Building C object CMakeFiles/yang.dir/src/parser_xml.c.o
[ 40%] Building C object CMakeFiles/yang.dir/src/parser_json.c.o
[ 44%] Building C object CMakeFiles/yang.dir/src/tree_schema.c.o
[ 48%] Building C object CMakeFiles/yang.dir/src/tree_data.c.o
/usr/home/rasto/lib/libyang/src/tree_data.c:360:5: warning: implicit declaration of function 'asprintf' is invalid in C99 [-Wimplicit-function-declaration]
asprintf(&xml, "<%s>%s</%s>", schema->name, (val_xml ? val_xml : ""), schema->name);
^
1 warning generated.
[ 51%] Building C object CMakeFiles/yang.dir/src/printer.c.o
[ 55%] Building C object CMakeFiles/yang.dir/src/xpath.c.o
/usr/home/rasto/lib/libyang/src/xpath.c:842:13: warning: implicit declaration of function 'asprintf' is invalid in C99 [-Wimplicit-function-declaration]
asprintf(&str_num, "%lld", (long long)set->value.num);
^
1 warning generated.
[ 59%] Building C object CMakeFiles/yang.dir/src/printer_yang.c.o
[ 62%] Building C object CMakeFiles/yang.dir/src/printer_xml.c.o
[ 66%] Building C object CMakeFiles/yang.dir/src/printer_tree.c.o
[ 70%] Building C object CMakeFiles/yang.dir/src/printer_info.c.o
[ 74%] Building C object CMakeFiles/yang.dir/src/printer_json.c.o
[ 77%] Building C object CMakeFiles/yang.dir/src/yang_types.c.o
[ 81%] Linking C shared library libyang.so
[ 81%] Built target yang
[ 85%] Building C object CMakeFiles/yanglint.dir/tools/lint/main.c.o
[ 88%] Building C object CMakeFiles/yanglint.dir/tools/lint/commands.c.o
/usr/home/rasto/lib/libyang/tools/lint/commands.c:940:18: warning: implicit declaration of function 'strdupa' is invalid in C99 [-Wimplicit-function-declaration]
char *args = strdupa(arg);
^
/usr/home/rasto/lib/libyang/tools/lint/commands.c:940:11: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
char *args = strdupa(arg);
^ ~~~~~~~~~~~~
2 warnings generated.
[ 92%] Building C object CMakeFiles/yanglint.dir/tools/lint/completion.c.o
[ 96%] Building C object CMakeFiles/yanglint.dir/linenoise/linenoise.c.o
[100%] Linking C executable yanglint
CMakeFiles/yanglint.dir/tools/lint/commands.c.o: In function cmd_help': /usr/home/rasto/lib/libyang/tools/lint/commands.c:(.text+0x1c4a): undefined reference tostrdupa'
libyang.so.0.5.33: undefined reference to get_current_dir_name' libyang.so.0.5.33: undefined reference to__isfinitel'
libyang.so.0.5.33: undefined reference to `__signbitl'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*
* Error code 1

Stop.
make[2]: stopped in /usr/home/rasto/lib/libyang/build
*** Error code 1

Stop.
make[1]: stopped in /usr/home/rasto/lib/libyang/build
*** Error code 1

Stop.
make: stopped in /usr/home/rasto/lib/libyang/build

@rkrejci
Copy link
Collaborator

rkrejci commented Feb 5, 2016

I'm not able to provide support on FreeBSD, but:

ad asprintf() - the warnings are strange, according to freeBSD man pages the asprintf() should be available since FreeBSD 2.2 and from that man page I don't see if there is a need for some special header.

ad linker error - seems to be the problem of -coverage option, I'll try to fix the problem.

@rkrejci rkrejci self-assigned this Feb 5, 2016
rkrejci added a commit that referenced this issue Feb 5, 2016
Seems that the -coverage option is not very portable (#17), so move
it from DEBUG build in cmake into the Travis config file, since we
codecov from Travis.
@rkrejci
Copy link
Collaborator

rkrejci commented Feb 5, 2016

strdupa() and get_current_dir_name() issues are expected on FreeBSD, in these cases we use GNU extensions that are probably not available on BSD systems.

@rkrejci
Copy link
Collaborator

rkrejci commented Feb 5, 2016

Please try it now with the devel branch, I'm not able to test it. If it will be ok, I'll merge the changes into the master branch.

@rastislavs
Copy link
Author

Thanks, I really appreciate your efforts to make libyang working also on Unixes. I have tested the code in devel. Some minor changes in includes are still needed in common.c:

1) #include <syscall.h> needs to be changed to #include <sys/syscall.h>
2) #include <limits.h> needs to be added (contains PATH_MAX definition)

Unfortunately, there are still two issues by linking:
libyang.so.0.6.4: undefined reference to__isfinitel'
libyang.so.0.6.4: undefined reference to `__signbitl'
I have no clue what these two mean :-( But they appear only by linking yanglint and the test_augment. Libyang itself builds and links successfully after the changes above. Tests are not being built in Release mode (= not really an issue), so an cmake option to not build yanglint could also be a solution.

Regarding asprintf() warnings: FreeBSD supports asprintf(), and it is available there by default, but the #define _XOPEN_SOURCE 700 hides it, since asprintf() is not part of the POSIX 2008 standard. I have tried to remove this define from affected sources - the warning has disappeared

rkrejci added a commit that referenced this issue Feb 8, 2016
@rkrejci
Copy link
Collaborator

rkrejci commented Feb 8, 2016

Seems that the undefined references relates to forgotten linkage of libmath. Please try 0.6.6 from devel branch.

@rastislavs
Copy link
Author

The #ifdef linux above including limits.h and sys/syscall.h common.c is wrong, should be #ifndef linux (although I think that these includes are also valid for Linux and the ifdef may not be needed at all). Apart of it, the build works without any errors and warnings!

@rastislavs
Copy link
Author

Sorry, to be more precise... We still need #include of limits.h on BSD, otherwise we get:
/home/rasto/tmp/libyang/src/common.c:111:14: error: use of undeclared identifier 'PATH_MAX'
char tmp[PATH_MAX];

I see that sys/sycall.h is not needed anymore on non-Linux platforms due to #ifdef in the code of ly_errno_location.

@rkrejci
Copy link
Collaborator

rkrejci commented Feb 8, 2016

At the end I removed the preprocessor directives from the include part to avoid multiple if(n)defs there - one would be for __USE_GNU, another for __linux__ so I believe that not having them there isn't an issue.

@rastislavs
Copy link
Author

Right, I think that this is the best solution. The build works fine now, thanks!

PavolVican pushed a commit that referenced this issue Feb 9, 2016
Seems that the -coverage option is not very portable (#17), so move
it from DEBUG build in cmake into the Travis config file, since we
codecov from Travis.
PavolVican pushed a commit that referenced this issue Feb 9, 2016
PavolVican pushed a commit that referenced this issue Feb 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants