-
Notifications
You must be signed in to change notification settings - Fork 559
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
Compilation errors during compiling Perl 5.40.0 for Emscripten/WebAssembly #22793
Comments
Yeah you need to remove
That is caused by your |
Thanks for the the advice. My current version (building all modules statically) below and it builds successfully.
Thanks! name: buildperlwasm
on: workflow_dispatch
env:
URLPERL: https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz
EMSCRIPTEN_VERSION: 3.1.73
jobs:
buildperlwasm:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v13
with:
version: ${{env.EMSCRIPTEN_VERSION}}
- name: Install Perl static native
shell: bash
run: |
mkdir native && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=native
cd native && BUILD_ZLIB=0 sh +x ./Configure -sde -Dman1dir=none -Dman3dir=none -Dprefix="$PWD/prefix" -Dusedevel -Uversiononly -Dlibs="-lpthread -ldl -lm -lutil -lc -lz" -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode" && cd -
make -C native
make -C native install
- name: Heredoc
run: |
cat <<'EOF' > hintfile_wasm.sh
osname="emscripten"
archname="wasm"
osvers="2.0.5"
myhostname='localhost'
mydomain='.local'
#TODO: almost all of the known_extensions are still being built. we should probably exclude some of them! (see also nonxs_ext)
#dynamic_ext=''
#noextensions='IPC/SysV'
cc="emcc"
ld="emcc"
#nm="`which llvm-nm`" # note from Glossary: 'After Configure runs, the value is reset to a plain "nm" and is not useful.'
ar="`which emar`" # note from Glossary: 'After Configure runs, the value is reset to a plain "ar" and is not useful.'
ranlib="`which emranlib`"
# Here's a fun one: apparently, when building perlmini.c, emcc notices that it's a symlink to perl.c, and compiles to perl.o
# (because there is no -o option), so the final perl ends up thinking it's miniperl (shown in "perl -v", @INC doesn't work, etc.).
# Because of this and other issues I've had with symlinks, I'm switching to hard links instead.
# (Another possible fix might be to fix the Makefile steps so that they use the -o option, but this solution works for now.)
#TODO Later: In NODEFS, does Perl's -e test work correctly on symlinks? (./t/TEST was having issues detecting ./t/perl, a symlink to ./perl).
lns="/bin/ln"
#prefix="/opt/perl"
inc_version_list="none"
loclibpth=''
glibpth=''
usemymalloc="n"
uselargefiles="n"
usenm='undef'
usemallocwrap="define"
d_procselfexe='undef'
d_dlopen='undef'
d_setlocale='undef'
d_perl_lc_all_category_positions_init='define'
d_perl_lc_all_separator='define'
d_perl_lc_all_uses_name_value_pairs='undef'
perl_lc_all_category_positions_init='{0,1,5,2,3,4}'
perl_lc_all_separator=''
dlsrc='none'
d_getgrgid_r='define'
d_getgrnam_r='define'
d_libname_unique="define"
d_getnameinfo='define'
d_setrgid='undef'
d_setruid='undef'
d_setproctitle='undef'
d_malloc_size='undef'
d_malloc_good_size='undef'
d_fdclose='undef'
#d_prctl='define' # hm, it's present in the libc source, but Configure shows Emscripten error output? -> for now, assume it's not available
# It *looks* like shm*, sem* and a few others exist in Emscripten's libc,
# but I'm not sure why Configure isn't detecting them. But at the moment I'm not going
# to worry about them, and just not build IPC-SysV.
d_clearenv='undef'
d_cuserid='undef'
d_eaccess='undef'
d_getspnam='undef'
d_msgctl='undef'
d_msgget='undef'
d_msgrcv='undef'
d_msgsnd='undef'
d_semget='undef'
d_semop='undef'
d_shmat='undef'
d_shmctl='undef'
d_shmdt='undef'
d_shmget='undef'
d_syscall='undef'
# Emscripten does not have signals support (documentation isn't 100% clear on this? but see "$EMSCRIPTEN/system/include/libc/setjmp.h")
# but if you do: grep -r 'Calling stub instead of' "$EMSCRIPTEN"
# you'll see the unsupported stuff (as of 1.37.35):
# signal() sigaction() sigprocmask() __libc_current_sigrtmin __libc_current_sigrtmax kill() killpg() siginterrupt() raise() pause()
# plus: "Calling longjmp() instead of siglongjmp()"
#d_sigaction='undef'
#d_sigprocmask='undef'
d_killpg='undef'
d_pause='undef'
d_sigsetjmp='undef' # this also disables Perl's use of siglongjmp() (see config.h)
# the others either aren't used by Perl (like siginterrupt) or can't be Configure'd (like kill)
#TODO Later: currently I've disabled Perl's use of signal() by patching the source - maybe there's a better way?
# Emscripten doesn't actually have these either (see "$EMSCRIPTEN/src/library.js")
d_wait4='undef'
d_waitpid='undef'
d_fork='define' # BUT, perl needs this one to at least build
d_vfork='undef'
d_pseudofork='undef'
i_pthread='undef'
d_pthread_atfork='undef'
d_pthread_attr_setscope='undef'
d_pthread_yield='undef'
# We're avoiding all the 64-bit stuff for now.
# Commented out stuff is correctly detected.
#TODO: JavaScript uses 64-bit IEEE double FP numbers - will Perl use those?
#TODO: Now that we've switched to WebAssembly, can we use 64 bits everywhere?
# see https://groups.google.com/forum/#!topic/emscripten-discuss/nWmO3gi8_Jg
#use64bitall='undef'
#use64bitint='undef'
#usemorebits='undef'
#usequadmath='undef'
#TODO Later: Why does Configure seem to ignore the following? (and do we care?)
d_quad='undef'
#TODO Later: The test for "selectminbits" seems to fail,
# the error appears to be coming from this line (because apparently stream.stream_ops is undefined):
# https://github.com/kripken/emscripten/blob/ddfc3e32f65/src/library_syscall.js#L750
# For now, just use this number from a build with an earlier version where this didn't fail:
selectminbits='32'
alignbytes='4'
optimize="-O2"
ldflags="$ldflags -lm -O2 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -Wno-almost-asm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s WASM=1"
# the following is needed for the "musl" libc provided by emscripten to provide all functions
# from Makefile.emcc / Makefile.micro -DSTANDARD_C -DPERL_USE_SAFE_PUTENV
# disable this warning, I don't think we need it - TODO: how to append this after -Wall?
ccflags="$ccflags -D_GNU_SOURCE -D_POSIX_C_SOURCE -DNO_MATHOMS -Wno-null-pointer-arithmetic"
# Configure apparently changes "-s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2" to "-s -s" when converting ccflags to cppflags
# this is the current hack/workaround: copy cppflags from config.sh and fix it (TODO Later: better way would be to patch Configure)
cppflags='-lm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -D_GNU_SOURCE -D_POSIX_C_SOURCE -DSTANDARD_C -DPERL_USE_SAFE_PUTENV -DNO_MATHOMS -Wno-null-pointer-arithmetic -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
libs='-lm'
EOF
- name: Install Perl static wasm
shell: bash
run: |
mkdir wasm && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=wasm
cp hintfile_wasm.sh wasm/hints/emscripten.sh
# https://github.com/Perl/perl5/issues/22728
cd wasm
emconfigure bash ./Configure -sde -Dman1dir=none -Dman3dir=none -Dhintfile=emscripten -Dsysroot=$(dirname $(which emcc))/system -Dhostperl=$PWD/../native/miniperl -Dhostgenerate=$PWD/../native/generate_uudmap -Dprefix=$PWD/prefix -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode"
sed -i 's/$(generated_pods)//' Makefile
sed -i 's/public = $(PERL_EXE) utilities/public = $(PERL_EXE)/' Makefile
emmake make
# LC_ALL="C" node ./perl -e 'print("hello world\n");' # fails with Perl locale errors
# emmake make install # fails while trying to use ./perl instead of host perls |
For the locale, have you tried adding to the Configure options Look at files in the |
I've tried this NO_LOCALE but this was still leading to broken config.g... |
At line number 17502 of Configure in current blead is the beginning of a C program. Extract that program, compile it, and run it, and report the results, including exit code. |
Here is the output:
exit code is 0 |
Thanks; I can't work on this right now, but maybe later tonight, and if not, first thing tomorrow my time UTC-7. I'll get you a Configure patch. |
In openwrt/packages#24512 there is also a lot of discussion of making a hintfile for bypassing this problem on musl systems... That's where I copied from: https://github.com/openwrt/packages/pull/24614/files
Emscripten is also musl libc-based |
It looks to me that this is the inevitable result currently of specifying d_setlocale to be undef, which is a bug in Configure and needs to be fixed, but is actually tangential to your problem. I have access to a system running Alpine Linux, which is using /usr/lib/x86_64-alpine-linux-musl/13.1.1, and it Configures fine on blead, yielding the following in
From what you said, I infer that you were getting Configure (unwisely) redirects the stderr of compilations to /dev/null. Let's find out why it isn't compiling. The attached patch allows that output to come out. What you did earlier was to compile on its own the code that is failing to compile in Configure And it compiled! but with a warning. The attached patch fixes the typo that led to that warning. So, get rid of setting d_setlocale, patch Configure with the attached, and rerun. Maybe it will fix it, but certainly should tell us enough to get to the root cause. |
@khwilliamson your patch worked! Hope you can upstream it!
I'll paste now the error produced by Last lines of my log:
|
See Perl#22793 This typo in a printf format causes some C compilations to fail; others to just warn. However stderr is redirected to /dev/null, so we weren't aware of this issue. When it fails, other issues cause perl to not be usable on the system.
Regarding locale: now that I removed all locale-related configs, curiously, it worked without issues. Not sure why I previously was getting Current
It is correct that host miniperl is used
Full workflow: name: buildperlwasm
on: workflow_dispatch
env:
URLPERL: https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz
EMSCRIPTEN_VERSION: 3.1.73
jobs:
buildperlwasm:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v13
with:
version: ${{env.EMSCRIPTEN_VERSION}}
- name: Install Perl static native
shell: bash
run: |
mkdir native && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=native
cd native && BUILD_ZLIB=0 sh +x ./Configure -sde -Dman1dir=none -Dman3dir=none -Dprefix="$PWD/prefix" -Dusedevel -Uversiononly -Dlibs="-lpthread -ldl -lm -lutil -lc -lz" -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode" && cd -
make -C native
make -C native install
- name: Heredoc
run: |
cat <<'EOF' > hintfile_wasm.sh
osname="emscripten"
archname="wasm"
osvers="2.0.5"
cc="emcc"
ld="emcc"
#nm="`which llvm-nm`" # note from Glossary: 'After Configure runs, the value is reset to a plain "nm" and is not useful.'
ar="`which emar`" # note from Glossary: 'After Configure runs, the value is reset to a plain "ar" and is not useful.'
ranlib="`which emranlib`"
#TODO: almost all of the known_extensions are still being built. we should probably exclude some of them! (see also nonxs_ext)
#dynamic_ext=''
#noextensions='IPC/SysV'
# Here's a fun one: apparently, when building perlmini.c, emcc notices that it's a symlink to perl.c, and compiles to perl.o
# (because there is no -o option), so the final perl ends up thinking it's miniperl (shown in "perl -v", @INC doesn't work, etc.).
# Because of this and other issues I've had with symlinks, I'm switching to hard links instead.
# (Another possible fix might be to fix the Makefile steps so that they use the -o option, but this solution works for now.)
#TODO Later: In NODEFS, does Perl's -e test work correctly on symlinks? (./t/TEST was having issues detecting ./t/perl, a symlink to ./perl).
lns="/bin/ln"
#prefix="/opt/perl"
inc_version_list="none"
loclibpth=''
glibpth=''
usemymalloc="n"
uselargefiles="n"
usenm='undef'
usemallocwrap="define"
d_procselfexe='undef'
d_dlopen='undef'
dlsrc='none'
d_getgrgid_r='define'
d_getgrnam_r='define'
d_libname_unique="define"
d_getnameinfo='define'
d_setrgid='undef'
d_setruid='undef'
d_setproctitle='undef'
d_malloc_size='undef'
d_malloc_good_size='undef'
d_fdclose='undef'
#d_prctl='define' # hm, it's present in the libc source, but Configure shows Emscripten error output? -> for now, assume it's not available
# It *looks* like shm*, sem* and a few others exist in Emscripten's libc,
# but I'm not sure why Configure isn't detecting them. But at the moment I'm not going
# to worry about them, and just not build IPC-SysV.
d_clearenv='undef'
d_cuserid='undef'
d_eaccess='undef'
d_getspnam='undef'
d_msgctl='undef'
d_msgget='undef'
d_msgrcv='undef'
d_msgsnd='undef'
d_semget='undef'
d_semop='undef'
d_shmat='undef'
d_shmctl='undef'
d_shmdt='undef'
d_shmget='undef'
d_syscall='undef'
# Emscripten does not have signals support (documentation isn't 100% clear on this? but see "$EMSCRIPTEN/system/include/libc/setjmp.h")
# but if you do: grep -r 'Calling stub instead of' "$EMSCRIPTEN"
# you'll see the unsupported stuff (as of 1.37.35):
# signal() sigaction() sigprocmask() __libc_current_sigrtmin __libc_current_sigrtmax kill() killpg() siginterrupt() raise() pause()
# plus: "Calling longjmp() instead of siglongjmp()"
#d_sigaction='undef'
#d_sigprocmask='undef'
d_killpg='undef'
d_pause='undef'
d_sigsetjmp='undef' # this also disables Perl's use of siglongjmp() (see config.h)
# the others either aren't used by Perl (like siginterrupt) or can't be Configure'd (like kill)
#TODO Later: currently I've disabled Perl's use of signal() by patching the source - maybe there's a better way?
# Emscripten doesn't actually have these either (see "$EMSCRIPTEN/src/library.js")
d_wait4='undef'
d_waitpid='undef'
d_fork='define' # BUT, perl needs this one to at least build
d_vfork='undef'
d_pseudofork='undef'
i_pthread='undef'
d_pthread_atfork='undef'
d_pthread_attr_setscope='undef'
d_pthread_yield='undef'
# We're avoiding all the 64-bit stuff for now.
# Commented out stuff is correctly detected.
#TODO: JavaScript uses 64-bit IEEE double FP numbers - will Perl use those?
#TODO: Now that we've switched to WebAssembly, can we use 64 bits everywhere?
# see https://groups.google.com/forum/#!topic/emscripten-discuss/nWmO3gi8_Jg
#use64bitall='undef'
#use64bitint='undef'
#usemorebits='undef'
#usequadmath='undef'
#TODO Later: Why does Configure seem to ignore the following? (and do we care?)
d_quad='undef'
#TODO Later: The test for "selectminbits" seems to fail,
# the error appears to be coming from this line (because apparently stream.stream_ops is undefined):
# https://github.com/kripken/emscripten/blob/ddfc3e32f65/src/library_syscall.js#L750
# For now, just use this number from a build with an earlier version where this didn't fail:
selectminbits='32'
alignbytes='4'
optimize="-O2"
ldflags="$ldflags -lm -O2 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -Wno-almost-asm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s WASM=1"
# the following is needed for the "musl" libc provided by emscripten to provide all functions
# from Makefile.emcc / Makefile.micro -DSTANDARD_C -DPERL_USE_SAFE_PUTENV
# disable this warning, I don't think we need it - TODO: how to append this after -Wall?
ccflags="$ccflags -D_GNU_SOURCE -D_POSIX_C_SOURCE -DNO_MATHOMS -Wno-null-pointer-arithmetic"
# Configure apparently changes "-s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2" to "-s -s" when converting ccflags to cppflags
# this is the current hack/workaround: copy cppflags from config.sh and fix it (TODO Later: better way would be to patch Configure)
cppflags='-lm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -D_GNU_SOURCE -D_POSIX_C_SOURCE -DSTANDARD_C -DPERL_USE_SAFE_PUTENV -DNO_MATHOMS -Wno-null-pointer-arithmetic -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
libs='-lm'
EOF
- name: Install Perl static wasm
shell: bash
run: |
mkdir wasm && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=wasm
cp hintfile_wasm.sh wasm/hints/emscripten.sh
cd wasm
emconfigure bash ./Configure -sde -Dman1dir=none -Dman3dir=none -Dmyhostname='localhost' -Dmydomain='.local' -Dperladmin=root -Dhintfile=emscripten -Dsysroot=$(dirname $(which emcc))/system -Dhostperl=$PWD/../native/miniperl -Dhostgenerate=$PWD/../native/generate_uudmap -Dprefix=$PWD/prefix -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode"
sed -i 's/$(generated_pods)//' Makefile
sed -i 's/public = $(PERL_EXE) utilities/public = $(PERL_EXE)/' Makefile
emmake make
node ./perl -e 'print("hello world\n");'
emmake make install |
In general our cross-compilation support is poor, and a lot of it is hard to fix without rewriting everything.
You could try to change the |
I've tried patching This is being printed by the installperl script: Line 230 in 342b57d
It checks if the produced perl binary has executable bit
|
Current
Is it possible to disabled pod-generation in some proper way? But otherwise, it completed! The |
If I comment out
Regarding If I uncomment So it for some reason tries to execute
Although for host perl build, it correctly uses miniperl:
How can I make it always use the host's So it appears that Extracting utils/Makefile (with variable substitutions)
# -*- mode: Perl; buffer-read-only: t -*-
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is built by utils/Makefile.PL.
# Any changes made here will be lost!
PERL = ../perl
REALPERL = ../perl I produced this file by running
# These use the Cwd extension. For statically-built perls, we
# need perl, not just miniperl.
my $perl = defined $Config{usedl} ? '../miniperl' : '../perl';
print $fh <<"EOT";
PERL = $perl
REALPERL = ../perl
RUN = # Used mainly cross-compilation setups. |
So the current workaround for The remaining question is how to bypass problems with pod generation? (and which makefile targets are pod-related? so that I could try running/debugging them manually one by one) name: buildperlwasm
on: workflow_dispatch
env:
URLPERL: https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz
EMSCRIPTEN_VERSION: 3.1.73
jobs:
buildperlwasm:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v13
with:
version: ${{env.EMSCRIPTEN_VERSION}}
- name: Install Perl static native
shell: bash
run: |
mkdir native && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=native
cd native && BUILD_ZLIB=0 sh +x ./Configure -sde -Dman1dir=none -Dman3dir=none -Dprefix="$PWD/prefix" -Dusedevel -Uversiononly -Dlibs="-lpthread -ldl -lm -lutil -lc -lz" -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode" && cd -
make -C native
make -C native install
- name: Heredoc
run: |
cat <<'EOF' > hintfile_wasm.sh
#TODO: almost all of the known_extensions are still being built. we should probably exclude some of them! (see also nonxs_ext)
#dynamic_ext=''
#noextensions='IPC/SysV'
# Here's a fun one: apparently, when building perlmini.c, emcc notices that it's a symlink to perl.c, and compiles to perl.o
# (because there is no -o option), so the final perl ends up thinking it's miniperl (shown in "perl -v", @INC doesn't work, etc.).
# Because of this and other issues I've had with symlinks, I'm switching to hard links instead.
# (Another possible fix might be to fix the Makefile steps so that they use the -o option, but this solution works for now.)
#TODO Later: In NODEFS, does Perl's -e test work correctly on symlinks? (./t/TEST was having issues detecting ./t/perl, a symlink to ./perl).
lns="/bin/ln"
loclibpth=''
glibpth=''
usemymalloc="n"
uselargefiles="n"
usenm='undef'
usemallocwrap="define"
d_procselfexe='undef'
d_dlopen='undef'
dlsrc='none'
d_getgrgid_r='define'
d_getgrnam_r='define'
d_libname_unique="define"
d_getnameinfo='define'
d_setrgid='undef'
d_setruid='undef'
d_setproctitle='undef'
d_malloc_size='undef'
d_malloc_good_size='undef'
d_fdclose='undef'
#d_prctl='define' # hm, it's present in the libc source, but Configure shows Emscripten error output? -> for now, assume it's not available
# It *looks* like shm*, sem* and a few others exist in Emscripten's libc,
# but I'm not sure why Configure isn't detecting them. But at the moment I'm not going
# to worry about them, and just not build IPC-SysV.
d_clearenv='undef'
d_cuserid='undef'
d_eaccess='undef'
d_getspnam='undef'
d_msgctl='undef'
d_msgget='undef'
d_msgrcv='undef'
d_msgsnd='undef'
d_semget='undef'
d_semop='undef'
d_shmat='undef'
d_shmctl='undef'
d_shmdt='undef'
d_shmget='undef'
d_syscall='undef'
# Emscripten does not have signals support (documentation isn't 100% clear on this? but see "$EMSCRIPTEN/system/include/libc/setjmp.h")
# but if you do: grep -r 'Calling stub instead of' "$EMSCRIPTEN"
# you'll see the unsupported stuff (as of 1.37.35):
# signal() sigaction() sigprocmask() __libc_current_sigrtmin __libc_current_sigrtmax kill() killpg() siginterrupt() raise() pause()
# plus: "Calling longjmp() instead of siglongjmp()"
#d_sigaction='undef'
#d_sigprocmask='undef'
d_killpg='undef'
d_pause='undef'
d_sigsetjmp='undef' # this also disables Perl's use of siglongjmp() (see config.h)
# the others either aren't used by Perl (like siginterrupt) or can't be Configure'd (like kill)
#TODO Later: currently I've disabled Perl's use of signal() by patching the source - maybe there's a better way?
# Emscripten doesn't actually have these either (see "$EMSCRIPTEN/src/library.js")
d_wait4='undef'
d_waitpid='undef'
d_fork='define' # BUT, perl needs this one to at least build
d_vfork='undef'
d_pseudofork='undef'
i_pthread='undef'
d_pthread_atfork='undef'
d_pthread_attr_setscope='undef'
d_pthread_yield='undef'
#TODO Later: Why does Configure seem to ignore the following? (and do we care?)
d_quad='undef'
#TODO Later: The test for "selectminbits" seems to fail,
# the error appears to be coming from this line (because apparently stream.stream_ops is undefined):
# https://github.com/kripken/emscripten/blob/ddfc3e32f65/src/library_syscall.js#L750
# For now, just use this number from a build with an earlier version where this didn't fail:
selectminbits='32'
alignbytes='4'
ldflags="$ldflags -lm -O2 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -Wno-almost-asm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s WASM=1"
# the following is needed for the "musl" libc provided by emscripten to provide all functions
# from Makefile.emcc / Makefile.micro -DSTANDARD_C -DPERL_USE_SAFE_PUTENV
# disable this warning, I don't think we need it - TODO: how to append this after -Wall?
ccflags="$ccflags -D_GNU_SOURCE -D_POSIX_C_SOURCE -DNO_MATHOMS -Wno-null-pointer-arithmetic"
# Configure apparently changes "-s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2" to "-s -s" when converting ccflags to cppflags
# this is the current hack/workaround: copy cppflags from config.sh and fix it (TODO Later: better way would be to patch Configure)
cppflags='-lm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -D_GNU_SOURCE -D_POSIX_C_SOURCE -DSTANDARD_C -DPERL_USE_SAFE_PUTENV -DNO_MATHOMS -Wno-null-pointer-arithmetic -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
EOF
- name: Install Perl static wasm
shell: bash
run: |
mkdir wasm && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=wasm
cp hintfile_wasm.sh wasm/hints/emscripten.sh
cd wasm
emconfigure bash ./Configure -sde -Dinc_version_list=none -Dman1dir=none -Dman3dir=none -Dosname="emscripten" -Darchname="wasm" -Dosvers="2.0.5" -Dmyhostname='localhost' -Dmydomain='.local' -Dperladmin=root -Dcc=emcc -Dld=emcc -Dar=$(which emar) -Dranlib=$(which emranlib) -Doptimize="-O2" -Dlibs='-lm' -Dhintfile=emscripten -Dsysroot=$(dirname $(which emcc))/system -Dhostperl=$PWD/../native/miniperl -Dhostgenerate=$PWD/../native/generate_uudmap -Dprefix=$PWD/prefix -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode"
sed -i 's/$(generated_pods)//' Makefile
emmake make utilities PERL=$PWD/../native/miniperl
emmake make
node ./perl -e 'print("hello world\n");'
chmod +x ./perl
emmake make install |
I added a few hacks for The The symlinking READMEs hack is needed for making It might be that necessity of these hacks reveal bugs in name: buildperlwasm
on: workflow_dispatch
env:
URLPERL: https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz
EMSCRIPTEN_VERSION: 3.1.73
jobs:
buildperlwasm:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v13
with:
version: ${{env.EMSCRIPTEN_VERSION}}
- name: Install Perl static native
shell: bash
run: |
mkdir native && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=native
cd native && BUILD_ZLIB=0 sh +x ./Configure -sde -Dman1dir=none -Dman3dir=none -Dprefix="$PWD/prefix" -Dusedevel -Uversiononly -Dlibs="-lpthread -ldl -lm -lutil -lc -lz" -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode" && cd -
make -C native
make -C native install
- name: Artifacts
uses: actions/upload-artifact@v4
with:
path: native/Makefile
- name: Heredoc
run: |
cat <<'EOF' > hintfile_wasm.sh
#TODO: almost all of the known_extensions are still being built. we should probably exclude some of them! (see also nonxs_ext)
#noextensions='IPC/SysV'
# Here's a fun one: apparently, when building perlmini.c, emcc notices that it's a symlink to perl.c, and compiles to perl.o
# (because there is no -o option), so the final perl ends up thinking it's miniperl (shown in "perl -v", @INC doesn't work, etc.).
# Because of this and other issues I've had with symlinks, I'm switching to hard links instead.
# (Another possible fix might be to fix the Makefile steps so that they use the -o option, but this solution works for now.)
#TODO Later: In NODEFS, does Perl's -e test work correctly on symlinks? (./t/TEST was having issues detecting ./t/perl, a symlink to ./perl).
usemymalloc="n"
uselargefiles="n"
usenm='undef'
usemallocwrap="define"
d_procselfexe='undef'
d_dlopen='undef'
dlsrc='none'
d_getgrgid_r='define'
d_getgrnam_r='define'
d_libname_unique="define"
d_getnameinfo='define'
d_setrgid='undef'
d_setruid='undef'
d_setproctitle='undef'
d_malloc_size='undef'
d_malloc_good_size='undef'
d_fdclose='undef'
#d_prctl='define' # hm, it's present in the libc source, but Configure shows Emscripten error output? -> for now, assume it's not available
# It *looks* like shm*, sem* and a few others exist in Emscripten's libc,
# but I'm not sure why Configure isn't detecting them. But at the moment I'm not going
# to worry about them, and just not build IPC-SysV.
d_clearenv='undef'
d_cuserid='undef'
d_eaccess='undef'
d_getspnam='undef'
d_msgctl='undef'
d_msgget='undef'
d_msgrcv='undef'
d_msgsnd='undef'
d_semget='undef'
d_semop='undef'
d_shmat='undef'
d_shmctl='undef'
d_shmdt='undef'
d_shmget='undef'
d_syscall='undef'
# Emscripten does not have signals support (documentation isn't 100% clear on this? but see "$EMSCRIPTEN/system/include/libc/setjmp.h")
# but if you do: grep -r 'Calling stub instead of' "$EMSCRIPTEN"
# you'll see the unsupported stuff (as of 1.37.35):
# signal() sigaction() sigprocmask() __libc_current_sigrtmin __libc_current_sigrtmax kill() killpg() siginterrupt() raise() pause()
# plus: "Calling longjmp() instead of siglongjmp()"
#d_sigaction='undef'
#d_sigprocmask='undef'
d_killpg='undef'
d_pause='undef'
d_sigsetjmp='undef' # this also disables Perl's use of siglongjmp() (see config.h)
# the others either aren't used by Perl (like siginterrupt) or can't be Configure'd (like kill)
#TODO Later: currently I've disabled Perl's use of signal() by patching the source - maybe there's a better way?
# Emscripten doesn't actually have these either (see "$EMSCRIPTEN/src/library.js")
d_wait4='undef'
d_waitpid='undef'
d_fork='define' # BUT, perl needs this one to at least build
d_vfork='undef'
d_pseudofork='undef'
i_pthread='undef'
d_pthread_atfork='undef'
d_pthread_attr_setscope='undef'
d_pthread_yield='undef'
#TODO Later: Why does Configure seem to ignore the following? (and do we care?)
d_quad='undef'
#TODO Later: The test for "selectminbits" seems to fail,
# the error appears to be coming from this line (because apparently stream.stream_ops is undefined):
# https://github.com/kripken/emscripten/blob/ddfc3e32f65/src/library_syscall.js#L750
# For now, just use this number from a build with an earlier version where this didn't fail:
selectminbits='32'
alignbytes='4'
ldflags="$ldflags -lm -O2 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -Wno-almost-asm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s WASM=1"
# the following is needed for the "musl" libc provided by emscripten to provide all functions
# from Makefile.emcc / Makefile.micro -DSTANDARD_C -DPERL_USE_SAFE_PUTENV
# disable this warning, I don't think we need it - TODO: how to append this after -Wall?
ccflags="$ccflags -D_GNU_SOURCE -D_POSIX_C_SOURCE -DNO_MATHOMS -Wno-null-pointer-arithmetic"
# Configure apparently changes "-s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2" to "-s -s" when converting ccflags to cppflags
# this is the current hack/workaround: copy cppflags from config.sh and fix it (TODO Later: better way would be to patch Configure)
cppflags='-lm -s ERROR_ON_UNDEFINED_SYMBOLS=0 -D_GNU_SOURCE -D_POSIX_C_SOURCE -DSTANDARD_C -DPERL_USE_SAFE_PUTENV -DNO_MATHOMS -Wno-null-pointer-arithmetic -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
EOF
- name: Install Perl static wasm
shell: bash
run: |
mkdir wasm && curl -L $URLPERL | tar -xzf - --strip-components=1 --directory=wasm
cp hintfile_wasm.sh wasm/hints/emscripten.sh
cd wasm
emconfigure bash ./Configure -sde -Dinc_version_list=none -Dloclibpth='' -Dglibpth='' -Dlns='/bin/ln' -Dman1dir=none -Dman3dir=none -Dosname="emscripten" -Darchname="wasm" -Dosvers="2.0.5" -Dmyhostname='localhost' -Dmydomain='.local' -Dperladmin=root -Dcc=emcc -Dld=emcc -Dar=$(which emar) -Dranlib=$(which emranlib) -Doptimize="-O2" -Dlibs='-lm' -Dhintfile=emscripten -Dsysroot=$(dirname $(which emcc))/system -Dhostperl=$PWD/../native/miniperl -Dhostgenerate=$PWD/../native/generate_uudmap -Dprefix=$PWD/prefix -Dstatic_ext="mro Devel/Peek File/DosGlob File/Glob Sys/Syslog Sys/Hostname PerlIO/via PerlIO/mmap PerlIO/encoding B attributes Unicode/Normalize Unicode/Collate threads threads/shared IPC/SysV re Digest/MD5 Digest/SHA SDBM_File Math/BigInt/FastCalc Data/Dumper I18N/Langinfo Time/HiRes Time/Piece IO Socket Hash/Util/FieldHash Hash/Util Filter/Util/Call POSIX Encode/Unicode Encode Encode/JP Encode/KR Encode/EBCDIC Encode/CN Encode/Symbol Encode/Byte Encode/TW Compress/Raw/Zlib Compress/Raw/Bzip2 MIME/Base64 Cwd Storable List/Util Fcntl Opcode"
ln -s $PWD/pod/perldelta.pod .; for f in README.* ; do ln $PWD/$f ..; done
emmake make utilities PERL="$PWD/../native/miniperl"
emmake make RUN_PERL="$PWD/../native/miniperl -Ilib -I."
chmod +x ./perl
emmake make install
cp ./perl.wasm ./prefix/bin
node ./prefix/bin/perl -e 'print("hello world\n");' |
See #22793 This typo in a printf format causes some C compilations to fail; others to just warn. However stderr is redirected to /dev/null, so we weren't aware of this issue. When it fails, other issues cause perl to not be usable on the system.
Related:
I had to set
d_setlocale='undef'
to circumvent the errors from #22728hintfile_wasm.sh
based on work of @haukex from blead...haukex:emperl5:emperl_v5.30.0Now the errors are: (note
siginfo_t
vsSiginfo_t
)Here is a full current GitHub Workflow Actions script:
The text was updated successfully, but these errors were encountered: