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 issue when building on windows #2149

Open
doums opened this issue Jan 17, 2024 · 3 comments
Open

perl issue when building on windows #2149

doums opened this issue Jan 17, 2024 · 3 comments

Comments

@doums
Copy link

doums commented Jan 17, 2024

Hi, we are trying to build a Rust project having indirect dependencies to openssl-sys.
When building on Microsoft Windows Server 2022 (github runner), we get the following perl error:

 error: failed to run custom build command for `openssl-sys v0.9.98`

Caused by:
  process didn't exit successfully: `D:\a\nym-vpn-client\nym-vpn-client\nym-vpn-desktop\src-tauri\target\release\build\openssl-sys-510aba73a2dc2d15\build-script-main` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  openssl-src: Enable the assembly language routines in building OpenSSL.
  running "perl" "./Configure" "--prefix=D:/a/nym-vpn-client/nym-vpn-client/nym-vpn-desktop/src-tauri/target/release/build/openssl-sys-e3460947fbbdac1d/out/openssl-build/install" "--openssldir=SYS$MANAGER:[OPENSSL]" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-capieng" "VC-WIN64A"

  --- stderr
Error:   Can't locate Locale/Maketext/Simple.pm in @INC (you may need to install the Locale::Maketext::Simple module) (@INC contains: /d/a/nym-vpn-client/nym-vpn-client/nym-vpn-desktop/src-tauri/target/release/build/openssl-sys-e3460947fbbdac1d/out/openssl-build/build/src/util/perl D \a\nym-vpn-client\nym-vpn-client\local\lib\perl5;D \a\nym-vpn-client\nym-vpn-client\local\lib\perl5\MSWin32-x64-multi-thread;D \a\_actions\shogo82148\actions-setup-perl\v1\scripts\lib /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl /d/a/nym-vpn-client/nym-vpn-client/nym-vpn-desktop/src-tauri/target/release/build/openssl-sys-e3460947fbbdac1d/out/openssl-build/build/src/external/perl/Text-Template-1.56/lib) at /usr/share/perl5/core_perl/Params/Check.pm line 6.
Error:   BEGIN failed--compilation aborted at /usr/share/perl5/core_perl/Params/Check.pm line 6.
Error:   Compilation failed in require at /usr/share/perl5/core_perl/IPC/Cmd.pm line 59.
Error:   BEGIN failed--compilation aborted at /usr/share/perl5/core_perl/IPC/Cmd.pm line 59.
Error:   Compilation failed in require at /d/a/nym-vpn-client/nym-vpn-client/nym-vpn-desktop/src-tauri/target/release/build/openssl-sys-e3460947fbbdac1d/out/openssl-build/build/src/util/perl/OpenSSL/config.pm line 19.
Error:   BEGIN failed--compilation aborted at /d/a/nym-vpn-client/nym-vpn-client/nym-vpn-desktop/src-tauri/target/release/build/openssl-sys-e3460947fbbdac1d/out/openssl-build/build/src/util/perl/OpenSSL/config.pm line 19.
Error:   Compilation failed in require at ./Configure line 23.
Error:   BEGIN failed--compilation aborted at ./Configure line 23.
  thread 'main' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\openssl-src-300.2.1+3.2.0\src\lib.rs:611:9:

I tried to setup Perl in the workflow before rust build

perl-version: '5.38'
distribution: strawberry

But it does not fix the issue.
Any help would be appreciated.

@sfackler
Copy link
Owner

(you may need to install the Locale::Maketext::Simple module)

@Qix-
Copy link

Qix- commented Mar 21, 2024

According to our CI, it is up to date when running cpan Locale::Maketext::Simple on a Windows github actions runner. So it is indeed already installed. Something else must be up.

@Qix-
Copy link

Qix- commented Mar 21, 2024

The issue is when you're building on windows using shell: bash. That puts the runner under MSYS/MINGW (not sure which one), which comes with its own /usr/bin/perl. @doums see https://github.com/nymtech/nym-vpn-client/pull/54/files#diff-7a42dc8739297053550b8882b7bf3fcc770725f51365f7b273ed5a7d9d91c329R151.

The giveaway was the @INC dirs that it outputs when erroring (broken out into lines for visibility:

(@INC contains:
/d/a/nym-vpn-client/nym-vpn-client/nym-vpn-desktop/src-tauri/target/release/build/openssl-sys-e3460947fbbdac1d/out/openssl-build/build/src/util/perl
D
\a\nym-vpn-client\nym-vpn-client\local\lib\perl5;D \a\nym-vpn-client\nym-vpn-client\local\lib\perl5\MSWin32-x64-multi-thread;D 
\a\_actions\shogo82148\actions-setup-perl\v1\scripts\lib
/usr/lib/perl5/site_perl
/usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl
...

Linux uses : as a path separator, but windows uses ; as its separator. Thus, you see the ; retained in the list, whereas the : from D:\ gets removed and is treated as a new path. That's what tipped me off as to what was happening (that, and the obvious linux-style paths).

Instead, you want the Windows perl. The openssl-src crate, which openssl-sys uses to build, allows you to override either PERL or OPENSSL_SRC_PERL. Run this as its own step prior to doing any builds:

      - name: Set Perl environment variables
        if: runner.os == 'Windows'
        run: |
          echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
          echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8

The trick is to not specify shell: bash in this step so that which.exe queries the Windows PATH and not MinGW's/MSYS's. The (...)[0] takes the first from where.exe since unlike Linux the Powershell version outputs all hits from the path. Then you stick them into the special file at $GITHUB_ENV which is used to populate default environment variables in all subsequent runs.

openssl-sys then started to build correctly for us.

Hope this helps :)

malor added a commit to xsnippet/xsnippet-api that referenced this issue Nov 26, 2024
See sfackler/rust-openssl#2149.

Apparently, in the Windows runner, commands executed in a `run` block
will use the version of Perl built into MinGW instead of the one
installed in the system, which breaks the openssl build because one of
the expected Perl modules can't be found.

There are different ways to fix this. The one suggested in this PR is
returning back to using the cargo action for "normal" (not cross
compilation) builds like it used to work before. My understanding is
that it helps by running cargo directly as opposed to running it from
Bash.

Alternatively, we could bypass the corresponding build steps in openssl
by providing locations of openssl source code via environment variables
like it is suggested in the rust-openssl issue linked above.
malor added a commit to xsnippet/xsnippet-api that referenced this issue Nov 26, 2024
See sfackler/rust-openssl#2149.

Apparently, in the Windows runner, commands executed in a `run` block
will use the version of Perl built into MinGW instead of the one
installed in the system, which breaks the openssl build because one of
the expected Perl modules can't be found.

There are different ways to fix this. The one suggested in this PR is
returning back to using the cargo action for "normal" (not cross
compilation) builds like it used to work before. My understanding is
that it helps by running cargo directly as opposed to running it from
Bash.

Alternatively, we could bypass the corresponding build steps in openssl
by providing locations of openssl source code via environment variables
like it is suggested in the rust-openssl issue linked above.
malor added a commit to xsnippet/xsnippet-api that referenced this issue Nov 26, 2024
See sfackler/rust-openssl#2149.

Apparently, in the Windows runner, commands executed in a `run` block
will use the version of Perl built into MinGW instead of the one
installed in the system, which breaks the openssl build because one of
the expected Perl modules can't be found.

There are different ways to fix this. The one suggested in this PR is
returning back to using the cargo action for "normal" (not cross
compilation) builds like it used to work before. My understanding is
that it helps by running cargo directly as opposed to running it from
Bash.

Alternatively, we could bypass the corresponding build steps in openssl
by providing locations of openssl source code via environment variables
like it is suggested in the rust-openssl issue linked above.
malor added a commit to xsnippet/xsnippet-api that referenced this issue Nov 26, 2024
See sfackler/rust-openssl#2149.

Apparently, in the Windows runner, commands executed in a `run` block
will use the version of Perl built into MinGW instead of the one
installed in the system, which breaks the openssl build because one of
the expected Perl modules can't be found.

There are different ways to fix this. The one suggested in this PR is
returning back to using the cargo action for "normal" (not cross
compilation) builds like it used to work before. My understanding is
that it helps by running cargo directly as opposed to running it from
Bash.

Alternatively, we could bypass the corresponding build steps in openssl
by providing locations of openssl source code via environment variables
like it is suggested in the rust-openssl issue linked above.
malor added a commit to xsnippet/xsnippet-api that referenced this issue Nov 26, 2024
See sfackler/rust-openssl#2149.

Apparently, in the Windows runner, commands executed in a `run` block
will use the version of Perl built into MinGW instead of the one
installed in the system, which breaks the openssl build because one of
the expected Perl modules can't be found.

There are different ways to fix this. The one suggested in this PR is
returning back to using the cargo action for "normal" (not cross
compilation) builds like it used to work before. My understanding is
that it helps by running cargo directly as opposed to running it from
Bash.

Alternatively, we could bypass the corresponding build steps in openssl
by providing locations of openssl source code via environment variables
like it is suggested in the rust-openssl issue linked above.
malor added a commit to xsnippet/xsnippet-api that referenced this issue Nov 26, 2024
See sfackler/rust-openssl#2149.

Apparently, in the Windows runner, commands executed in a `run` block
will use the version of Perl built into MinGW instead of the one
installed in the system, which breaks the openssl build because one of
the expected Perl modules can't be found.

There are different ways to fix this. The one suggested in this PR is
returning back to using the cargo action for "normal" (not cross
compilation) builds like it used to work before. My understanding is
that it helps by running cargo directly as opposed to running it from
Bash.

Alternatively, we could bypass the corresponding build steps in openssl
by providing locations of openssl source code via environment variables
like it is suggested in the rust-openssl issue linked above.
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