Skip to content

Fix build on Centos 7 #20

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

Merged
merged 2 commits into from
Jan 12, 2021
Merged

Fix build on Centos 7 #20

merged 2 commits into from
Jan 12, 2021

Conversation

olegrok
Copy link
Contributor

@olegrok olegrok commented Dec 29, 2020

Initially I planed only CentOS 7 build. However finally I faced a problem with github actions.

Please, read description in commit messages.

Closes #19

@olegrok olegrok requested review from Totktonada and tsafin December 29, 2020 16:28
@olegrok olegrok force-pushed the olegrok/19-centos7-build branch from 7f096f9 to 711990c Compare December 30, 2020 06:17
CMakeLists.txt Outdated
@@ -11,6 +11,10 @@ set(CMAKE_MODULE_PATH

include(cmake/utils.cmake)

# Set CFLAGS/CXXFLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -std=gnu11")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe enable -Werror only on debug build, just like in tarantool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure it's a good idea. Tarantool has separate target for Debug build in CI but we don't have that for modules.

I don't see nothing bad to show and prevent as much warnings as possible.

Copy link
Member

Choose a reason for hiding this comment

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

  1. You can run cmake . -DCMAKE_BUILD_TYPE=Debug|Release|RelWithDebInfo && make VERBOSE=1 and see different compilation flags.
  2. https://github.com/tarantool/tarantool/blob/efc30ccf8393a1aad19d4c17299842899d003caa/cmake/compiler.cmake#L372-L373 (it comes from this commit and this issue).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can, but I think it's more relevant for Tarantool with default Debug mode. But I'm not sure it's so relevant for modules.

E.g. in avro-schema: https://github.com/tarantool/avro-schema/blob/3b2d264e1f7828dda034aa5cae30184f2b9adbfa/CMakeLists.txt#L21-L23

Copy link
Member

Choose a reason for hiding this comment

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

Proportionally to amount of code.

Default cmake flags for different build types are different.

Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

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

LGTM in general.

Before this patch an attempt to build on CentOS 7 (gcc 4.8.5)
failed with error:
```
[ 63%] Building C object src/CMakeFiles/merger.dir/compat/utils.c.o
[ 72%] Building C object src/CMakeFiles/merger.dir/merger/merger.c.o
/tmp/luarocks_tuple-merger-0.0.1-1-Cwe2jE/tuple-merger/src/merger/merger.c: In function 'luaT_merger_new_parse_sources':
/tmp/luarocks_tuple-merger-0.0.1-1-Cwe2jE/tuple-merger/src/merger/merger.c:306:2: error: 'for' loop initial declarations are only allowed in C99 mode
  for (uint32_t i = 0; i < source_count; ++i) {
  ^
/tmp/luarocks_tuple-merger-0.0.1-1-Cwe2jE/tuple-merger/src/merger/merger.c:306:2: note: use option -std=c99 or -std=gnu99 to compile your code
gmake[5]: *** [src/CMakeFiles/merger.dir/merger/merger.c.o] Error 1
```

However we can't simply enable c99 mode because "typeof" is gcc
extension and otherwise it failed with:
```
/opt/tarantool/tuple-merger/src/merger/merger.c:917:54: error: unused parameter ‘base’ [-Werror=unused-parameter]
 luaL_merge_source_tuple_destroy(struct merge_source *base)
                                                      ^
In file included from /opt/tarantool/tuple-merger/src/merger/merger.c:44:0:
/opt/tarantool/tuple-merger/src/merger/merger.c: In function ‘luaL_merge_source_tuple_next_impl’:
/usr/local/include/tarantool/module.h:201:16: error: expected declaration specifiers or ‘...’ before (’ token
  const typeof( ((type *)0)->member  ) *__mptr = (ptr); \
                ^
/opt/tarantool/tuple-merger/src/merger/merger.c:937:38: note: in expansion of macro ‘container_of’
  struct merge_source_tuple *source = container_of(base,
```

So, finally after enable gnu99 mode all seems to be ok.

Closes #19
Seems set-env is deprecated this patch replaces it.
See for details https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

Following issue should be fixed:
```
Error: Unable to process command '::set-env name=PATH::/Users/runner/work/tuple-merger/tuple-merger/share/bin:/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/lib/ruby/gems/2.7.0/bin:/usr/local/opt/ruby/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/usr/local/go/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Users/runner/Library/Android/sdk/ndk-bundle:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools:/Users/runner/.ghcup/bin:/Users/runner/hostedtoolcache/stack/2.5.1/x64' successfully.
Error: The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
```
@olegrok olegrok force-pushed the olegrok/19-centos7-build branch from 711990c to b02a546 Compare January 12, 2021 04:03
@tsafin tsafin merged commit 287e9c6 into master Jan 12, 2021
@tsafin tsafin deleted the olegrok/19-centos7-build branch January 12, 2021 07:13
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

Successfully merging this pull request may close these issues.

failed to build module on centos:7
3 participants