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

Perl 5.40: error: invalid preprocessing directive #PERL_LC_ALL_CATEGORY_POSITIONS_INIT in make on Solaris 10 #22728

Closed
Here-Be-Saoirse opened this issue Nov 9, 2024 · 25 comments

Comments

@Here-Be-Saoirse
Copy link

Module:

Description
Perl 5.40 will fail to build on Solaris 10. Using GCC 9.5.0, and the configure line ./Configure -Duse64bitint -Dusethreads -Dprefix=/opt/FSYS/packages/ -des, reporting the following errors:

echo @`sh  cflags "optimize='-O'" opmini.o` -fPIC -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c
@/opt/FSYS/packages/bin/gcc -c -DPERL_CORE -D_REENTRANT -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -mcpu=v9 -m64 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O -Wall -fPIC -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c
In file included from perl.h:46,
                 from op.c:163:
config.h:3640:3: error: invalid preprocessing directive #PERL_LC_ALL_USES_NAME_VALUE_PAIRS
 3640 | # PERL_LC_ALL_USES_NAME_VALUE_PAIRS   /**/
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
config.h:3641:4: error: invalid preprocessing directive #PERL_LC_ALL_SEPARATOR
 3641 | #  PERL_LC_ALL_SEPARATOR  /**/
      |    ^~~~~~~~~~~~~~~~~~~~~
config.h:3642:4: error: invalid preprocessing directive #PERL_LC_ALL_CATEGORY_POSITIONS_INIT
 3642 | #  PERL_LC_ALL_CATEGORY_POSITIONS_INIT   /**/
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [makefile:313: opmini.o] Error 1

Steps to Reproduce
On Solaris 10 SPARC do: ./Configure -Duse64bitint -Dusethreads -Dprefix=/opt/FSYS/packages/ -- note: This may not be reproduceable on others' systems, since gcc9.5 isn't available in OpenCSW or other sources for Solaris 10, we are using our own build

Expected behavior
We expected it to at least start to build. It immediately fails

Perl configuration

Perl couldn't build, so `perl -v` output isn't relevant

OS: SunOS 5.10 SPARC Solaris 10
Compiler: GCC 9.5.0
Linker: ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.1522

@jkeenan
Copy link
Contributor

jkeenan commented Nov 9, 2024

Module:

Description Perl 5.40 will fail to build on Solaris 10. Using GCC 9.5.0, and the configure line ./Configure -Duse64bitint -Dusethreads -Dprefix=/opt/FSYS/packages/ -des, reporting the following errors:

Three suggestions/questions:

  1. Start with just ./Configure -des, run make miniperl and make test_prep, and note how far you got. Then, add your other switches one at a time, e.g., first -Dusethreads, then -Duse64bitint. Repeat attempts to configure and build. At what point do you start to get these failures during make?
  2. I understand you are using your own build of gcc to build perl. What results do you get if you use a "stock" version of gcc from GNU?
  3. Could you attach the content of config.sh, which is an end-product from ./Configure?

@Here-Be-Saoirse
Copy link
Author

@jkeenan
1: Same every time
2: Does the same thing with a stock GNU gcc
3: config.sh attached
config.sh.txt

@mauke
Copy link
Contributor

mauke commented Nov 9, 2024

Did Configure at any point say something about Failed to compile lc_all probe?

@Here-Be-Saoirse
Copy link
Author

@mauke
Yup! Just re-did the config and...
Checking to see if you have setlocale() and its behavior
Your system has setlocale()...
and it seems sane; you don't have a C.UTF-8 locale
Checking the syntax of LC_ALL when categories are set to different locales...
Failed to compile lc_all probe

@jkeenan
Copy link
Contributor

jkeenan commented Nov 10, 2024

Is this ./Configure switch Dprefix=/opt/FSYS/packages/ needed in order to get your custom gcc build? Is there any way you could, for testing purposes, try to configure without it?

@Here-Be-Saoirse
Copy link
Author

@jkeenan
It's needed because we're packaging this stuff for distribution. Doing it without that switch does the same thing.

@jkeenan
Copy link
Contributor

jkeenan commented Nov 10, 2024

@jkeenan It's needed because we're packaging this stuff for distribution. Doing it without that switch does the same thing.

Thanks. Were you successful building earlier versions of perl (e.g., 5.38) on this platform with the same configuration switches? If so, would you be able to bisect to identify the "breaking" commit?

@Here-Be-Saoirse
Copy link
Author

@jkeenan
Haven't tried 538, will give that a spin. Bisecting like that is gonna be complex with a screenreader, but we'll try.

@mauke
Copy link
Contributor

mauke commented Nov 10, 2024

As far as I can tell, this is a bug in Configure. If it detects setlocale() exists, it tries to compile and run a probe program, but if that fails for any reason, it throws away the error message, deletes the probe program, outputs "Failed to compile lc_all probe", but keeps running without setting d_lc_all_separator, d_perl_lc_all_uses_name_value_pairs or d_perl_lc_all_category_positions_init, so the generated config.h file is syntactically invalid.

@Here-Be-Saoirse
Copy link
Author

@mauke
Is there a way to override that and fix it? Sorry if our questions are stupid, we're new to doing all of this

@mauke
Copy link
Contributor

mauke commented Nov 10, 2024

I'm not sure either.

Any fix or override probably involves patching Configure.

At the line where it says

    $echo "Failed to compile lc_all probe" >&4

(which I think is line 17836 in your copy), you could add the lines

    d_perl_lc_all_uses_name_value_pairs="$undef"
    d_perl_lc_all_separator="$undef"
    perl_lc_all_separator=
    d_perl_lc_all_category_positions_init="$undef"
    perl_lc_all_category_positions_init=

... which I think is a safe default.

A real fix involves figuring out why the probe doesn't compile and change the code. You can make it output the compiler invocation it's trying to run by adding

    echo "$cc -o try $optimize $ccflags $ldflags try.c $libs"

The code for try.c is embedded in Configure about 30 lines further up, but you could also have Configure make you a copy by adding

    cp try.c ../lc_all_probe.c

Then you could manually run the compiler on the probe file and see why it's failing.

@Here-Be-Saoirse
Copy link
Author

@mauke
Wilco. Interesting thing, it looks like 538 doesn't have that error. Maybe. running the compile now to see if it does

@Here-Be-Saoirse
Copy link
Author

looks like 538 doesn't have the error. Interesting.

@khwilliamson
Copy link
Contributor

This was changed for 5.40; so don't waste your time on 5.38 or bisecting. I'll look at Configure and give you a patch

@Here-Be-Saoirse
Copy link
Author

@khwilliamson
Appreciate it. Shipped perl on this box is perl 5.8, OpenCSW only has 5.10.

@khwilliamson
Copy link
Contributor

But it would be useful to us for you to do as @mauke suggested at #22728 (comment) and post the results

@Here-Be-Saoirse
Copy link
Author

once we get a decent editor on this thing, we shall

@Here-Be-Saoirse
Copy link
Author

right, that seemed to work right up until gcc -m64 -o miniperl \ opmini.o perlmini.o universalmini.o gv.o toke.o perly.o pad.o regcomp.o regcomp_debug.o regcomp_invlist.o regcomp_study.o regcomp_trie.o regexec.o dump.o util.o mg.o reentr.o mro_core.o keywords.o builtin.o class.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o peep.o doop.o doio.o utf8.o taint.o deb.o globals.o perlio.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o caretx.o dquote.o time64.o miniperlmain.o -lpthread -lsocket -lnsl -ldl -lm -lc - that coughs up a hairball about undefined references to __stack_chk_fail. Presumably would have to build without SSP?

@khwilliamson
Copy link
Contributor

khwilliamson commented Nov 10, 2024

I think you must hae taken @mauke's suggestion to add some defaults, and that got you past this issue, and onto the stack one, which is outside my expertise.

It would be helpful to us if you did this to Configure

cp try.c ../lc_all_probe.c

as mauke suggested and then try compiling it to see why it's failing.

We need to patch Configure to take action when this doesn't compile; but it would be better to understand why it's not compiling as well.

I'd be interested to see what would happen in your case if you didn't patch Configure, but instead called it with the additional parameter -Accflags=-DNO_LOCALE That just might work to avoid patching for now.

@Here-Be-Saoirse
Copy link
Author

honestly we're about out of energy for fucking arouund with this

@vadimkantorov
Copy link

vadimkantorov commented Nov 27, 2024

Also hit this error when trying to compile Perl 5.40.0 for WebAssembly :(

@vadimkantorov
Copy link

vadimkantorov commented Nov 27, 2024

Adding -Accflags=-DNO_LOCALE to the Configure command made no effect (the define got passed through, but made no difference)

@khwilliamson if you give me a patch command for Configure (release 5.40.0), I can try it out...

but yeah, even if lc_all probe cannot compile, it should not produce a broken config.h

More complete error:

echo @`sh  cflags "optimize='-O2'" opmini.o`  -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c
@emcc -c -DPERL_CORE -D_GNU_SOURCE -D_POSIX_C_SOURCE -DSTANDARD_C -DPERL_USE_SAFE_PUTENV -DNO_MATHOMS -Wno-null-pointer-arithmetic -DNO_LOCALE -pipe -fstack-protector-strong -O2 -Wall -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c
In file included from op.c:163:
In file included from ./perl.h:46:
./config.h:3640:3: error: invalid preprocessing directive
 3640 | # PERL_LC_ALL_USES_NAME_VALUE_PAIRS     /**/
      |   ^
./config.h:3641:4: error: invalid preprocessing directive
 3641 | #  PERL_LC_ALL_SEPARATOR        /**/
      |    ^
./config.h:3642:4: error: invalid preprocessing directive
 3642 | #  PERL_LC_ALL_CATEGORY_POSITIONS_INIT          /**/
      |    ^
In file included from op.c:163:
./perl.h:1088:9: warning: 'PERL_USE_SAFE_PUTENV' macro redefined [-Wmacro-redefined]
 1088 | #define PERL_USE_SAFE_PUTENV
      |         ^
<command line>:6:9: note: previous definition is here
    6 | #define PERL_USE_SAFE_PUTENV 1
      |         ^
1 warning and 3 errors generated.
emcc: error: '/home/runner/work/_temp/a11c9425-ef60-4e2f-9ddd-938ec773ceda/emsdk-main/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/home/runner/work/_temp/a11c9425-ef60-4e2f-9ddd-938ec773ceda/emsdk-main/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -DPERL_CORE -D_GNU_SOURCE -D_POSIX_C_SOURCE -DSTANDARD_C -DPERL_USE_SAFE_PUTENV -DNO_MATHOMS -Wno-null-pointer-arithmetic -DNO_LOCALE -pipe -fstack-protector-strong -O2 -Wall -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c -o opmini.o' failed (returned 1)
make: *** [makefile:313: opmini.o] Error 1

@vadimkantorov
Copy link

vadimkantorov commented Nov 28, 2024

(which I think is line 17836 in your copy), you could add the lines

Adding this changed something helped. Now fighting some other related errors...

./perl.h:1088:9: warning: 'PERL_USE_SAFE_PUTENV' macro redefined [-Wmacro-redefined]
 1088 | #define PERL_USE_SAFE_PUTENV
      |         ^
<command line>:6:9: note: previous definition is here
    6 | #define PERL_USE_SAFE_PUTENV 1
      |         ^
locale.c:8812:43: error: use of undeclared identifier 'PERL_LC_ALL_CATEGORY_POSITIONS_INIT'
 8812 |         int lc_all_category_positions[] = PERL_LC_ALL_CATEGORY_POSITIONS_INIT;
      |                                           ^
locale.c:8813:31: error: invalid application of 'sizeof' to an incomplete type 'int[]'
 8813 |         STATIC_ASSERT_STMT(   C_ARRAY_LENGTH(lc_all_category_positions)
      |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 8814 |                            == LC_ALL_INDEX_);
      |                            ~~~~~~~~~~~~~~~~~
./handy.h:2924:34: note: expanded from macro 'C_ARRAY_LENGTH'
 2924 | #define C_ARRAY_LENGTH(a)       (sizeof(a)/sizeof((a)[0]))
      |                                        ^
./perl.h:4296:71: note: expanded from macro 'STATIC_ASSERT_STMT'
 4296 | #define STATIC_ASSERT_STMT(COND)      STMT_START { STATIC_ASSERT_DECL(COND); } STMT_END
      |                                                    ~~~~~~~~~~~~~~~~~~~^~~~~
./perl.h:4291:55: note: expanded from macro 'STATIC_ASSERT_DECL'
 4291 | #  define STATIC_ASSERT_DECL(COND)    STATIC_ASSERT_1(COND, __LINE__)
      |                                       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
./perl.h:4290:57: note: expanded from macro 'STATIC_ASSERT_1'
 4290 | #  define STATIC_ASSERT_1(COND, SUFFIX) STATIC_ASSERT_2(COND, SUFFIX)
      |                                         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
./perl.h:4288:59: note: expanded from macro 'STATIC_ASSERT_2'
 4288 |         unsigned int _static_assertion_failed_##SUFFIX : (COND) ? 1 : -1; \
      |                                                           ^~~~
locale.c:8817:18: error: invalid application of 'sizeof' to an incomplete type 'int[]'
 8817 |              i < C_ARRAY_LENGTH(lc_all_category_positions);
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./handy.h:2924:34: note: expanded from macro 'C_ARRAY_LENGTH'
 2924 | #define C_ARRAY_LENGTH(a)       (sizeof(a)/sizeof((a)[0]))
      |                                        ^~~
1 warning and 3 errors generated.

Maybe need to somehow adjust those lines... Likely, we need to set PERL_LC_ALL_CATEGORY_POSITIONS_INIT to something not empty, so that C_ARRAY_LENGTH can take 0th element...

@khwilliamson
Copy link
Contributor

@Here-Be-Saoirse as a follow-up, the patch in #22793 likely fixes the locale portions of this issue

@vadimkantorov
Copy link

(But also, the default there in Configure probably should be fixed too - to at least not produce broken C code...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants