-
Notifications
You must be signed in to change notification settings - Fork 318
Allow build on Solaris 11.4 #2453
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
base: master
Are you sure you want to change the base?
Conversation
michalvasko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes need to be discussed more but also change the base branch to devel, we do not accept PRs into master. But we plan to make a new release soon when devel will be merged into master so it should not matter to you.
| else() | ||
| # global C flags | ||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -std=c11") | ||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but the C standard needs to be specified because various compilers use different default standards. And before deciding the exact solution I would like to know the details of the issue. Is the compiler too old on Solaris that does not support this C revision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, declarations for vasprintf and strndup are missing:
/scratch/psumbera/libyang/src/ly_common.c:704:11: error: implicit declaration of function 'vasprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration]
704 | len = vasprintf(&addition, format, fp);
| ^~~~~~~~~
| vsprintf
/scratch/psumbera/libyang/src/ly_common.c: In function 'ly_parse_int':
/scratch/psumbera/libyang/src/ly_common.c:733:11: error: implicit declaration of function 'strndup'; did you mean 'strncmp'? [-Wimplicit-function-declaration]
733 | str = strndup(val_str, val_len);
| ^~~~~~~
| strncmp
/scratch/psumbera/libyang/src/ly_common.c:733:9: error: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
733 | str = strndup(val_str, val_len);
| ^
/scratch/psumbera/libyang/src/ly_common.c: In function 'ly_parse_uint':
/scratch/psumbera/libyang/src/ly_common.c:773:9: error: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
773 | str = strndup(val_str, val_len);
| ^
Note that you can play with Solaris via https://github.com/vmactions/shell-solaris .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there are some macro definitions missing, you can learn about those in the man pages. The VM seems nice but to have a lasting effect we would need to add it into our automatic actions, which does not seem possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for macros. This is also possibiltiy:
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,6 +77,9 @@ if(WIN32)
else()
# global C flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -std=c11")
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__")
+ endif()
endif()
include_directories(${PROJECT_BINARY_DIR}/libyang ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/plugins_exts)
As for Solaris CI. It's possible: https://github.com/rust-lang/libc/blob/d58c1f4f9ae01648b342d7dead291d08655677c4/.github/workflows/ci.yaml#L278
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine although the macro looks very non-standard. Better adding macros than changing the C standard. As for the CI, I may take a look at it later and add an action for Solaris in our CI.
| #ifdef __sun__ | ||
| if (1) { | ||
| #else | ||
| if ((file->d_type == DT_UNKNOWN) || (file->d_type == DT_LNK)) { | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain because just looking at this I do not understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d_type is not part of struct dirent on Solaris.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, then it should ideally be properly detected in by cmake and then handled here. I can add that and it may be faster, if you want.
Builds on Solaris 11.4 with libyan (CESNET/libyang#2453): ./bootstrap.sh MAKE=gmake ./configure --disable-protobuf gmake gmake check
No description provided.