diff --git a/.github/actions/setup-wsl-runner/action.yaml b/.github/actions/setup-wsl-runner/action.yaml new file mode 100644 index 000000000000..5d30fd6ad0aa --- /dev/null +++ b/.github/actions/setup-wsl-runner/action.yaml @@ -0,0 +1,50 @@ +name: Setup Windows WSL Runner +description: 'Setup a WSL Runner for building and testing Erlang/OTP' + +inputs: + installer_name: + default: false + github_token: + description: 'GITHUB_TOKEN' + default: '${{ github.token }}' + +runs: + using: composite + steps: + - name: Set timezone to CET + shell: cmd + run: tzutil /s "W. Europe Standard Time" + + - uses: Vampire/setup-wsl@v3.1.3 + with: + distribution: Ubuntu-18.04 + + - name: Install WSL dependencies + shell: wsl-bash {0} + run: apt update && apt install -y make autoconf unzip zip + + - name: Download source archive + uses: actions/download-artifact@v4.1.8 + with: + name: otp_prebuilt + + - name: Download installer + if: inputs.installer_name != 'false' + uses: actions/download-artifact@v4.1.8 + with: + name: otp_win32_installer + + - name: Download tests + if: inputs.installer_name != 'false' + uses: actions/download-artifact@v4.1.8 + with: + name: otp_tests + + - name: Install OTP + if: inputs.installer_name != 'false' + shell: cmd + run: | + echo %cd% + start "" /WAIT ${{ inputs.installer_name }} /S /D=%CD%\release\win32\ + dir %cd% + dir %cd%\release\win32\ \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 36ce23901695..6639f151a65b 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -34,7 +34,7 @@ name: Build and check Erlang/OTP on: - push: + #push: pull_request: schedule: - cron: 0 1 * * * @@ -278,22 +278,24 @@ jobs: path: otp/liberlang.xcframework build-windows: + name: Build Erlang/OTP (Windows) + needs: pack + if: needs.pack.outputs.c-code-changes + runs-on: windows-2022 defaults: run: shell: wsl-bash {0} env: WXWIDGETS_VERSION: 3.2.6 - name: Build Erlang/OTP (Windows) - runs-on: windows-2022 - needs: pack - if: needs.pack.outputs.c-code-changes + outputs: + installer_name: ${{ steps.compile-erlang.outputs.installer_name }} + steps: - - uses: Vampire/setup-wsl@5ff2c045a05fd477a71b5419d50c5a228a52468e # ratchet:Vampire/setup-wsl@v4.1.0 - with: - distribution: Ubuntu-18.04 - - - name: Install WSL dependencies - run: apt update && apt install -y g++-mingw-w64 gcc-mingw-w64 make autoconf unzip + - name: Setup nl behaviour for wsl + shell: cmd + run: git config --global core.autocrlf input + - uses: actions/checkout@v4.2.1 + - uses: ./.github/actions/setup-wsl-runner - name: Install openssl shell: cmd @@ -349,6 +351,9 @@ jobs: name: otp_prebuilt - name: Compile Erlang + id: compile-erlang + env: + WSLENV: GITHUB_OUTPUT/p run: | mkdir -p /mnt/c/opt/local64/pgm/ cp -R wxWidgets /mnt/c/opt/local64/pgm/wxWidgets-${{ env.WXWIDGETS_VERSION }} @@ -368,8 +373,11 @@ jobs: fi ./otp_build boot -a ./otp_build release -a - cp /mnt/c/opt/local64/pgm/wxWidgets-${{ env.WXWIDGETS_VERSION }}/3rdparty/webview2/runtimes/win-x64/native/WebView2Loader.dll $ERL_TOP/release/win32/erts-*/bin/ + ./otp_build debuginfo_win32 ./otp_build installer_win32 + echo "installer_name=$(ls release/win32/otp*.exe | xargs basename)" >> $GITHUB_OUTPUT + make release_tests + zip -r tests.zip release/tests - name: Upload installer uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # ratchet:actions/upload-artifact@v4.6.0 @@ -377,6 +385,12 @@ jobs: name: otp_win32_installer path: otp/release/win32/otp*.exe + - name: Upload tests + uses: actions/upload-artifact@v4.4.0 + with: + name: otp_tests + path: otp/tests.zip + build-flavors: name: Build Erlang/OTP (Types and Flavors) runs-on: ubuntu-latest @@ -493,6 +507,123 @@ jobs: - name: Run dialyzer run: docker run -v $PWD/:/github otp '/github/scripts/run-dialyzer' + test-windows: + name: Test Win64 Erlang/OTP + needs: [pack, build-windows] + defaults: + run: + shell: wsl-bash {0} + runs-on: windows-2022 + if: needs.pack.outputs.changes != '[]' + strategy: + matrix: + type: ${{ fromJson(needs.pack.outputs.all) }} + # type: ${{ fromJson(needs.pack.outputs.changes) }} + # type: ["os_mon","sasl"] + fail-fast: false + steps: + - name: Setup nl behaviour for wsl + shell: cmd + run: git config --global core.autocrlf input + - uses: actions/checkout@v4.2.1 + - uses: ./.github/actions/setup-wsl-runner + with: + installer_name: ${{ needs.build-windows.outputs.installer_name }} + + - name: Run tests + id: run-tests + run: | + set -x + unzip -q tests.zip + export ERL_TOP="$(pwd)" + export MAKEFLAGS=-j$(($(nproc) + 2)) + + eval `./otp_build env_win32 x64` + + export PATH=`pwd`/release/win32/bin/:$PATH + + APP="${{ matrix.type }}" + TYPE=opt + ## Need to specialize for epmd, emulator and debug + case "${APP}" in + debug) + echo "No debug tests on windows" + ;; + *) + (cd release/tests/test_server && erl.exe -env USER ${USER} -emu_type $TYPE -noinput -eval "ts:install()" -eval "ts:run($APP,[batch])" -s init stop) + if grep "^=result[ ]*failed:" release/tests/test_server/ct_run.*/tests.${APP}_test.logs/run*/suite.log; then + exit 1 + fi + ;; + esac + + - name: Cleanup tests + if: ${{ !cancelled() && matrix.type != 'debug' }} + run: tar czf ${{ matrix.type }}_win32_test_results.tar.gz release/tests/test_server + - name: Upload test results + uses: actions/upload-artifact@v4.4.0 + if: ${{ !cancelled() && matrix.type != 'debug' }} + with: + name: ${{ matrix.type }}_win32_test_results + path: ${{ matrix.type }}_win32_test_results.tar.gz + + system-test-windows: + name: Test Win64 Erlang/OTP (system) + defaults: + run: + shell: wsl-bash {0} + runs-on: windows-2022 + if: ${{ !cancelled() }} # Run even if the need has failed + needs: [test-windows, build-windows] + steps: + - name: Setup nl behaviour for wsl + shell: cmd + run: git config --global core.autocrlf input + - uses: actions/checkout@v4.2.1 + - uses: ./.github/actions/setup-wsl-runner + with: + installer_name: ${{ needs.build-windows.outputs.installer_name }} + + - name: Download test results + uses: actions/download-artifact@v4.1.8 + - name: Merge test results + run: | + shopt -s nullglob + for file in *_win32_test_results/*.tar.gz; do + tar xvzf $file + done + export PATH=`pwd`/release/win32/bin/:$PATH + cd release/tests/test_server && ct_run.exe -noshell -refresh_logs $(wslpath -w `pwd`) + + - name: Run system tests + run: | + set -x + unzip -q -o tests.zip + + export ERL_TOP="$(pwd)/otp" + export MAKEFLAGS=-j$(($(nproc) + 2)) + + eval `./otp_build env_win32 x64` + + export PATH=`pwd`/release/win32/bin/:$PATH + + (cd release/tests/test_server && erl.exe -noshell -eval "ts:install()" -eval "ts:run(system,[batch])" -s init stop) + if grep "^=result[ ]*failed:" release/tests/test_server/ct_run.*/tests.system_test.logs/run*/suite.log; then + exit 1 + fi + + - name: Cleanup tests + if: ${{ !cancelled() }} + run: | + tar czf test_results_win32.tar.gz release/tests/test_server + + - name: Upload test results + uses: actions/upload-artifact@v4.4.0 + if: ${{ !cancelled() }} + with: + name: test_results_win32 + path: test_results_win32.tar.gz + test: name: Test Erlang/OTP runs-on: ubuntu-latest @@ -544,13 +675,13 @@ jobs: run: | rm -rf make_test_dir/otp || true sudo bash -c "chown -R `whoami` make_test_dir && chmod -R +r make_test_dir" - tar czf ${{ matrix.type }}_test_results.tar.gz make_test_dir + tar czf ${{ matrix.type }}_ubuntu_test_results.tar.gz make_test_dir - name: Upload test results uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # ratchet:actions/upload-artifact@v4.6.0 if: ${{ !cancelled() }} with: - name: ${{ matrix.type }}_test_results - path: ${{ matrix.type }}_test_results.tar.gz + name: ${{ matrix.type }}_ubuntu_test_results + path: ${{ matrix.type }}_ubuntu_test_results.tar.gz system-test: name: Test Erlang/OTP (system) @@ -568,7 +699,7 @@ jobs: run: | shopt -s nullglob mkdir -p make_test_dir - for file in *_test_results/*.tar.gz; do + for file in *_ubuntu_test_results/*.tar.gz; do tar xzf $file done docker run -v $PWD/make_test_dir:/buildroot/otp/erts/make_test_dir otp \ diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in index a35bc38d4099..f926ab69291f 100644 --- a/erts/emulator/Makefile.in +++ b/erts/emulator/Makefile.in @@ -559,6 +559,10 @@ release_spec: all $(INSTALL_DATA) $(RELEASE_INCLUDES) "$(RELEASE_PATH)/usr/include" $(INSTALL_DATA) $(RELEASE_INCLUDES) "$(RELSYSDIR)/include" $(INSTALL_PROGRAM) $(BINDIR)/$(EMULATOR_EXECUTABLE) "$(RELSYSDIR)/bin" +ifeq ($(TARGET),win32) + $(INSTALL_DATA) $(BINDIR)/$(EMULATOR_EXECUTABLE:.dll=.pdb) "$(RELSYSDIR)/bin" + $(INSTALL_DATA) $(BINDIR)/$(FLAVOR_EXECUTABLE:.dll=.pdb) "$(RELSYSDIR)/bin" +endif ifeq ($(RELEASE_LIBBEAM),yes) $(INSTALL_DIR) "$(RELSYSDIR)/lib" $(INSTALL_PROGRAM) $(BINDIR)/$(EMULATOR_LIB) "$(RELSYSDIR)/lib" diff --git a/erts/emulator/beam/erl_bif_coverage.c b/erts/emulator/beam/erl_bif_coverage.c index 0ff51b8de0ac..6c508b711587 100644 --- a/erts/emulator/beam/erl_bif_coverage.c +++ b/erts/emulator/beam/erl_bif_coverage.c @@ -374,6 +374,7 @@ get_cover_id_line(Process* c_p, const BeamCodeHeader* hdr) for (i = hdr->line_coverage_len - 1; i >= 0; i--) { Eterm coverage = am_error; Uint* coverage_array = hdr->coverage; + Sint coverage_data; unsigned cover_id; if (!hdr->line_coverage_valid[i]) { @@ -388,7 +389,8 @@ get_cover_id_line(Process* c_p, const BeamCodeHeader* hdr) if (location == LINE_INVALID_LOCATION) { continue; } - coverage = make_small(MIN(coverage_array[i], MAX_SMALL)); + coverage_data = coverage_array[i]; + coverage = make_small(MIN(coverage_data, MAX_SMALL)); cover_id = loc2id[i]; tmp = TUPLE2(hp, make_small(cover_id), coverage); hp += 3; diff --git a/erts/emulator/test/smoke_test_SUITE.erl b/erts/emulator/test/smoke_test_SUITE.erl index b59390a85482..f99761e51cad 100644 --- a/erts/emulator/test/smoke_test_SUITE.erl +++ b/erts/emulator/test/smoke_test_SUITE.erl @@ -102,16 +102,16 @@ native_atomics(Config) when is_list(Config) -> end. jump_table(Config) when is_list(Config) -> - case erlang:system_info(beam_jump_table) of - true -> - ok; - false -> + case {erlang:system_info(beam_jump_table), + erlang:system_info(emu_flavor)} of + {false, emu} -> case erlang:system_info(build_type) of opt -> ct:fail(optimized_without_beam_jump_table); BT -> {comment, "No beam jump table, but build type is " ++ atom_to_list(BT)} - end + end; + _ -> ok end. diff --git a/erts/epmd/src/Makefile.in b/erts/epmd/src/Makefile.in index f21ac5e38652..640ac84fbe76 100644 --- a/erts/epmd/src/Makefile.in +++ b/erts/epmd/src/Makefile.in @@ -120,6 +120,9 @@ include $(ERL_TOP)/make/otp_release_targets.mk release_spec: all $(INSTALL_DIR) "$(RELEASE_PATH)/erts-$(VSN)/bin" $(INSTALL_PROGRAM) $(INSTALL_PROGS) "$(RELEASE_PATH)/erts-$(VSN)/bin" +ifeq ($(TARGET),win32) + $(INSTALL_DATA) $(INSTALL_PROGS:.exe=.pdb) "$(RELEASE_PATH)/erts-$(VSN)/bin" +endif release_docs_spec: diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in index 2778fb1504d9..6f8750d25ff9 100644 --- a/erts/etc/common/Makefile.in +++ b/erts/etc/common/Makefile.in @@ -467,6 +467,7 @@ $(OBJDIR)/safe_string.o: $(ETC)/safe_string.c $(RC_GENERATED) # erl_call $(BINDIR)/erl_call@EXEEXT@: $(ERL_TOP)/lib/erl_interface/bin/$(TARGET)/erl_call@EXEEXT@ $(ld_verbose)cp $< $@ + $(ld_verbose)cp $(<:.exe=.pdb) $(@:.exe=.pdb) ifneq ($(TARGET),win32) $(BINDIR)/$(ERLEXEC): $(OBJDIR)/$(ERLEXEC).o $(ERTS_LIB) @@ -545,6 +546,10 @@ ifneq ($(TARGET), win32) endif ifneq ($(INSTALL_PROGS),) $(INSTALL_PROGRAM) $(INSTALL_PROGS) "$(RELEASE_PATH)/erts-$(VSN)/bin" +ifeq ($(TARGET),win32) + $(INSTALL_DATA) $(INSTALL_PROGS:.exe=.pdb) "$(RELEASE_PATH)/erts-$(VSN)/bin" + $(INSTALL_DATA) $(INSTALL_PROGS:.dll=.pdb) "$(RELEASE_PATH)/erts-$(VSN)/bin" +endif endif ifneq ($(INSTALL_TOP),) $(INSTALL_SCRIPT) $(INSTALL_TOP) "$(RELEASE_PATH)" diff --git a/erts/etc/win32/wsl_tools/vc/cc.sh b/erts/etc/win32/wsl_tools/vc/cc.sh index 493c6b640365..2d3d524f803d 100755 --- a/erts/etc/win32/wsl_tools/vc/cc.sh +++ b/erts/etc/win32/wsl_tools/vc/cc.sh @@ -123,6 +123,8 @@ while test -n "$1" ; do MD=-MD; fi OPTIMIZED_BUILD=true;; + -O0) + ;; -O*) # Optimization hardcoded OPTIMIZE_FLAGS="-Ox -Z7"; diff --git a/erts/lib_src/Makefile.in b/erts/lib_src/Makefile.in index 392d10f49341..cdc51b4db5f2 100644 --- a/erts/lib_src/Makefile.in +++ b/erts/lib_src/Makefile.in @@ -455,6 +455,9 @@ INTERNAL_RELEASE_LIBS= \ .PHONY: release_spec release_spec: all $(INSTALL_PROGRAM) $(YCF_EXECUTABLE) "$(RELSYSDIR)/bin" +ifeq ($(TARGET),win32) + $(INSTALL_DATA) $(YCF_EXECUTABLE:.exe=.pdb) "$(RELEASE_PATH)/erts-$(VSN)/bin" +endif ifneq ($(strip $(RELEASE_INCLUDES)),) $(INSTALL_DIR) "$(RELSYSDIR)/include" $(INSTALL_DIR) "$(RELEASE_PATH)/usr/include" diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl index bc3b0ae92cf4..55743777feae 100644 --- a/lib/sasl/src/systools_make.erl +++ b/lib/sasl/src/systools_make.erl @@ -1589,9 +1589,10 @@ preloaded() -> erts_binary_filter() -> Cmds = ["typer", "dialyzer", "ct_run", "yielding_c_fun", "erlc"], + Extensions = [".exe", ".pdb"], case os:type() of {unix,_} -> Cmds; - {win32,_} -> [ [Cmd, ".exe"] || Cmd <- Cmds] + {win32,_} -> [ [Cmd, Ext] || Cmd <- Cmds, Ext <- Extensions] end. %%______________________________________________________________________ diff --git a/lib/sasl/test/systools_SUITE.erl b/lib/sasl/test/systools_SUITE.erl index a72b65f0f777..e246dafd5530 100644 --- a/lib/sasl/test/systools_SUITE.erl +++ b/lib/sasl/test/systools_SUITE.erl @@ -1119,12 +1119,25 @@ erts_tar(Config) -> "start","start_erl.src","start.src","to_erl"], ["ct_run","dialyzer","erlc","typer","yielding_c_fun"]}; {win32, _} -> - {["beam.smp.pdb","erl.exe", - "erl.pdb","erl_log.exe","erlexec.dll","erlsrv.exe","heart.exe", - "start_erl.exe","beam.smp.dll", - "epmd.exe","erl.ini","erl_call.exe", - "erlexec.pdb","escript.exe","inet_gethost.exe"], - ["dialyzer.exe","erlc.exe","yielding_c_fun.exe","ct_run.exe","typer.exe"]} + Files = ["beam.smp.dll", + "epmd.exe", + "erl.exe", + "erl_call.exe", + "erl_log.exe", + "erlexec.dll", + "erlsrv.exe", + "escript.exe", + "heart.exe", + "inet_gethost.exe", + "start_erl.exe"], + PdbFiles = ["beam.jit.pdb"] ++ [filename:rootname(F) ++ ".pdb" || F <- Files], + IgnoredFiles = ["ct_run.exe", + "dialyzer.exe", + "erlc.exe", + "typer.exe", + "yielding_c_fun.exe"], + PdbIgnored = [filename:rootname(F) ++ ".pdb" || F <- IgnoredFiles], + {["erl.ini"] ++ Files ++ PdbFiles, IgnoredFiles ++ PdbIgnored} end, ErtsTarContent = @@ -1134,9 +1147,11 @@ erts_tar(Config) -> || File <- tar_contents(TarName), string:equal(filename:dirname(File),ERTS_DIR), %% Filter out beam.*.smp.* - re:run(filename:basename(File), "beam\\.[^\\.]+\\.smp(\\.dll)?") == nomatch, + re:run(filename:basename(File), "beam\\.[^\\.]+\\.smp(\\.dll|\\.pdb)?") == nomatch, %% Filter out beam.*.emu.* - re:run(filename:basename(File), "beam\\.([^\\.]+\\.)?emu(\\.dll)?") == nomatch, + re:run(filename:basename(File), "beam\\.([^\\.]+\\.)?emu(\\.dll\\.pdb)?") == nomatch, + %% Filter out beam.*.jit.pdb + re:run(filename:basename(File), "beam\\.[^\\.]+\\.?jit\\.pdb") == nomatch, %% Filter out any erl_child_setup.* re:run(filename:basename(File), "erl_child_setup\\..*") == nomatch ]) diff --git a/make/test_target_script.sh b/make/test_target_script.sh index 868436a3c5ce..3900a4ce880a 100755 --- a/make/test_target_script.sh +++ b/make/test_target_script.sh @@ -27,6 +27,14 @@ LIGHT_CYAN='\033[1;36m' BOLD='\033[1m' NC='\033[0m' +ERL=erl +WIN_ERL_TOP="$ERL_TOP" + +if [ "${WSLcross}" = "true" ] +then + ERL=erl.exe + WIN_ERL_TOP=$(w32_path.sh -m "$ERL_TOP") +fi print_highlighted_msg_with_printer () { COLOR=$1 @@ -169,8 +177,8 @@ then echo "The tests will start in a few seconds..." sleep 45 cd "$ERL_TOP/release/tests/test_server" - erl -noinput -eval "ts:install(),erlang:halt()" - erl -noinput -eval "ts:run([all_tests,batch]),erlang:halt()" + $ERL -noinput -eval "ts:install(),erlang:halt()" + $ERL -noinput -eval "ts:run([all_tests,batch]),erlang:halt()" exit $? fi @@ -271,7 +279,7 @@ fi # Compile test server and configure if [ ! -f "$ERL_TOP/lib/common_test/test_server/variables" ]; then cd "$ERL_TOP/lib/common_test/test_server" - ( ${MAKE:-make} && erl -noshell -eval "ts:install()." -s init stop ) > "$INSTALL_TEST_LOG" 2>&1 + ( ${MAKE:-make} && $ERL -noshell -eval "ts:install()." -s init stop ) > "$INSTALL_TEST_LOG" 2>&1 if [ $? != 0 ] then cat "$INSTALL_TEST_LOG" @@ -283,8 +291,8 @@ fi # Run ct_run cd $MAKE_TEST_REL_DIR -erl -sname test -noshell -pa "$ERL_TOP/lib/common_test/test_server" \ - -eval "ts:compile_datadirs(\"$ERL_TOP/lib/common_test/test_server/variables\",\"*_SUITE_data\")."\ +$ERL -sname test -noshell -pa "$WIN_ERL_TOP/lib/common_test/test_server" \ + -eval "ts:compile_datadirs(\"$WIN_ERL_TOP/lib/common_test/test_server/variables\",\"*_SUITE_data\")."\ -s init stop > "$COMPILE_TEST_LOG" 2>&1 if [ $? != 0 ] @@ -322,7 +330,6 @@ then else WIN_MAKE_TEST_CT_LOGS=`w32_path.sh -m "$MAKE_TEST_CT_LOGS"` WIN_MAKE_TEST_DIR=`w32_path.sh -m "$MAKE_TEST_DIR"` - WIN_ERL_TOP=`w32_path.sh -m "$ERL_TOP"` "$CT_RUN.exe" -logdir $WIN_MAKE_TEST_CT_LOGS\ -pa "$WIN_ERL_TOP/lib/common_test/test_server"\ -config "$WIN_ERL_TOP/lib/common_test/test_server/ts.config"\ diff --git a/otp_build b/otp_build index 793f09444c15..c9ca707650df 100755 --- a/otp_build +++ b/otp_build @@ -1257,20 +1257,13 @@ do_update_ex_doc () do_debuginfo_win32 () { setup_make - (cd erts/emulator && $MAKE MAKE="$MAKE" TARGET=$TARGET debug) || exit 1 + ($MAKE MAKE="$MAKE" TARGET=$TARGET TYPE=debug) || exit 1 if [ -z "$1" ]; then - RELDIR="$ERL_TOP/release/$TARGET" + RELDIR="$ERL_TOP/release/$TARGET" else - RELDIR="$1" + RELDIR="$1" fi - BINDIR="$ERL_TOP/bin/$TARGET" - EVSN=`grep '^VSN' erts/vsn.mk | sed 's,^VSN.*=[^0-9]*\([0-9].*\)$,@\1,g;s,^[^@].*,,g;s,^@,,g'` - for f in beam.debug.smp.dll beam.smp.pdb beam.debug.smp.dll.pdb erl.pdb erlexec.pdb; do - if [ -f $BINDIR/$f ]; then - rm -f $RELDIR/erts-$EVSN/bin/$f - cp $BINDIR/$f $RELDIR/erts-$EVSN/bin/$f - fi - done + ($MAKE release RELEASE_ROOT="$RELDIR" MAKE="$MAKE" TARGET=$TARGET TYPE=debug) || exit 1 } do_installer_win32 ()