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

1.18.x extension build failed #470

Closed
vladimirtemnikov opened this issue Jan 30, 2024 · 11 comments
Closed

1.18.x extension build failed #470

vladimirtemnikov opened this issue Jan 30, 2024 · 11 comments

Comments

@vladimirtemnikov
Copy link

vladimirtemnikov commented Jan 30, 2024

Hello, latest version's ext can't compile.
Specs: MacOS 14.3, Apple silicon, Ruby 3.2.3
1.17.1 compiles well.

mkmf.log
have_func: checking for fdatasync() in fcntl.h... -------------------- yes

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -o conftest -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/gmp/lib     -lruby.3.2  -lpthread  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -o conftest -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/gmp/lib     -lruby.3.2  -lpthread  "
conftest.c:16:57: error: use of undeclared identifier 'fdatasync'
 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))fdatasync; return !p; }
    |                                                         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <fcntl.h>
4: 
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9:   if (argc > 1000000) {
10:     int (* volatile tp)(void)=(int (*)(void))&t;
11:     printf("%d", (*tp)());
12:   }
13: 
14:   return !!argv[argc];
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))fdatasync; return !p; }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -o conftest -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/gmp/lib     -lruby.3.2  -lpthread  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <fcntl.h>
4: 
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9:   if (argc > 1000000) {
10:     int (* volatile tp)(void)=(int (*)(void))&t;
11:     printf("%d", (*tp)());
12:   }
13: 
14:   return !!argv[argc];
15: }
16: extern void fdatasync();
17: int t(void) { fdatasync(); return 0; }
/* end */

--------------------

block in append_cppflags: checking for whether _GNU_SOURCE is accepted as CPPFLAGS... -------------------- no

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe  _GNU_SOURCE -Werror -c conftest.c"
clang: error: no such file or directory: '_GNU_SOURCE'
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

--------------------

block in append_cflags: checking for whether -O3 is accepted as CFLAGS... -------------------- yes

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe  -O3 -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

--------------------

block in append_cflags: checking for whether -std=c99 is accepted as CFLAGS... -------------------- yes

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe -O3  -std=c99 -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

--------------------

compiling bootsnap.c
bootsnap.c:343:7: error: call to undeclared function 'fdatasync'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  343 |   if (fdatasync(cache_fd) < 0) {
      |       ^
1 error generated.
make: *** [bootsnap.o] Error 1
@casperisfine
Copy link
Contributor

Hum, that is surprising for two reasons:

  • First I mostly develop on the same OS and hardware and it works fine for me.
  • That code is under #ifdef HAVE_FDATASYNC which is tested in extconf.rb

All this to say that you very certainly have that function.

So I don't know what is happening to you, but there must be something wrong with your installation somehow.

@vladimirtemnikov vladimirtemnikov changed the title 1.18.0 extension build failed 1.18.x extension build failed Jan 30, 2024
@casperisfine
Copy link
Contributor

Actually your mkmf.log shows it:

have_func: checking for fdatasync() in fcntl.h... -------------------- yes

@vladimirtemnikov
Copy link
Author

@casperisfine thank you for quick response.
Trying to figure out what's wrong.

Strange that conftest fails literally below check for fdatasync:

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -o conftest -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/gmp/lib     -lruby.3.2  -lpthread  "
conftest.c:16:57: error: use of undeclared identifier 'fdatasync'
 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))fdatasync; return !p; }
    |                                                         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <fcntl.h>
4: 
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9:   if (argc > 1000000) {
10:     int (* volatile tp)(void)=(int (*)(void))&t;
11:     printf("%d", (*tp)());
12:   }
13: 
14:   return !!argv[argc];
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))fdatasync; return !p; }
/* end */

@XrXr
Copy link
Contributor

XrXr commented Jan 30, 2024

The function is actually declared in unistd.h. I guess on Linux fcntl.h also includes it. You can see in the second check that passes that mkmf is declaring its own function, basically just checking for linkage.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html#tag_16_123

@vladimirtemnikov
Copy link
Author

vladimirtemnikov commented Jan 30, 2024

Adding extern int fdatasync(int); before calling fixes the problem, but I think it is more crutch than real fix (I'm not familiar with building exts).

As a source: php/php-src#7122

@casperisfine
Copy link
Contributor

Fixed in 34f1be9, thank you so much Alan, you da real MVP.

@vladimirtemnikov you can try the main branch, but might want to hold off anyway because I think I spotted another issue.

@vladimirtemnikov
Copy link
Author

@casperisfine @XrXr that was quick, thank you ❤️

@vladimirtemnikov
Copy link
Author

vladimirtemnikov commented Jan 30, 2024

@casperisfine used main branch, still does not work:

have_func: checking for fdatasync() in unistd.h... -------------------- yes

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -o conftest -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/gmp/lib     -lruby.3.2  -lpthread  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib "clang -o conftest -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/arm64-darwin23 -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/backward -I/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/include/ruby-3.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/vladimirtemnikov/.local/share/mise/installs/ruby/3.2.3/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/gmp/lib     -lruby.3.2  -lpthread  "
conftest.c:16:57: error: use of undeclared identifier 'fdatasync'
   16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))fdatasync; return !p; }
      |                                                         ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <unistd.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     int (* volatile tp)(void)=(int (*)(void))&t;
11:     printf("%d", (*tp)());
12:   }
13: 
14:   return !!argv[argc];
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))fdatasync; return !p; }
/* end */

May be this could help, idk: #470 (comment)

@casperisfine
Copy link
Contributor

That is wild.

@casperisfine casperisfine reopened this Jan 30, 2024
@casperisfine
Copy link
Contributor

Alright, if PHP and PG do it, I don't see why not use that workaround. Fixed in d4b4666

@vladimirtemnikov
Copy link
Author

@casperisfine finally built, thank you again!

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

3 participants