8000 Fix error at Ruby CI by soutaro · Pull Request #2445 · ruby/rbs · GitHub
[go: up one dir, main page]

Skip to content

Fix error at Ruby CI #2445

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 6 commits into from
May 9, 2025
Merged

Fix error at Ruby CI #2445

merged 6 commits into from
May 9, 2025

Conversation

soutaro
Copy link
Member
@soutaro soutaro commented May 2, 2025

This PR is to fix build errors which is reported in ruby/ruby#13237.

  • This PR adds CI job to compile without C23 extensions.
  • You can compile in C99 mode in your local environment with compile_c99 Rake task

soutaro added a commit to soutaro/ruby that referenced this pull request May 2, 2025
src/lexstate.c Outdated
rbs_token_t NullToken = { .type = NullType, .range = {} };
rbs_token_t NullToken = { .type = NullType, .range = {0} };
Copy link
Contributor
@amomchilov amomchilov May 2, 2025

Choose a reason for hiding this comment

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

You'll need to make the same change in 2 other places:

rbs/src/parser.c

Line 3418 in 6c08f20

.constant_pool = {},

static rbs_constant_pool_t RBS_GLOBAL_CONSTANT_POOL_STORAGE = {};

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we reuse NULL_RANGE defined 3 lines under if we move the line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Reusing NULL_RANGE didn't work with clang-15, on GitHub Actions... 😢

```
error C2059: syntax error: '}'
```
@soutaro soutaro force-pushed the fix-vc-compilation-error branch from 405356c to 5f78a6b Compare May 7, 2025 03:45
@soutaro
Copy link
Member Author
soutaro commented May 7, 2025

I've been trying a CI task to compile the library without C23 extensions, but not finished yet...

@soutaro soutaro force-pushed the fix-vc-compilation-error branch from 8df7b12 to ccdef8b Compare May 8, 2025 08:52
@@ -106,3 +106,31 @@ jobs:
- run: bundle exec rake test:valgrind
env:
RUBY_FREE_AT_EXIT: 1
C99_compile:
Copy link
Member Author

Choose a reason for hiding this comment

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

This job compiles the extension without C23 extensions to ensure it compiles with C99 compilers.

To compile it with clang, not gcc, the macos platform is used.

@@ -0,0 +1,10 @@
#ifdef __clang__
Copy link
Member Author

Choose a reason for hiding this comment

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

Including ruby.h caused compilation errors without C23 extensions. This macro is to suppress diagnostics in the header files.

@@ -183,4 +183,6 @@ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instan
return ID2SYM(rb_intern3((const char *) constant->start, constant->length, ctx.encoding));
}
}

rb_raise(rb_eRuntimeError, "Unknown node type: %d", instance->type);
Copy link
Member Author

Choose a reason for hiding this comment

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

GCC reports warning: control reaches end of non-void function [-Wreturn-type] diagnostic here.

@@ -13,5 +13,9 @@

append_cflags ['-std=gnu99', '-Wimplicit-fallthrough', '-Wunused-result']
append_cflags ['-O0', '-g'] if ENV['DEBUG']
if ENV["TEST_NO_C23"]
Copy link
Member Author
@soutaro soutaro May 8, 2025

Choose a reason for hiding this comment

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

Using append_cflags doesn't work because the compilation with -Wc2x-extensions fails. (I guess this is because ruby.h issues diagnostics without C23 extensions.)

@soutaro soutaro added this pull request to the merge queue May 8, 2025
@soutaro soutaro removed this pull request from the merge queue due to a manual request May 8, 2025
@soutaro soutaro added this to the RBS 4.0 milestone May 8, 2025
@soutaro soutaro added this pull request to the merge queue May 9, 2025
Merged via the queue into master with commit cb36fcb May 9, 2025
22 checks passed
@soutaro soutaro deleted the fix-vc-compilation-error branch May 9, 2025 01:31
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.

3 participants
0