From 3a162745c62b1f46580bdc0851f17ac46937197c Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Mon, 11 Nov 2019 15:41:43 +0100 Subject: Add wsl config as an environment to otp build tools Allows "cross" building with native windows from WSL linux. Currently we only support building on the windows disk, old WSL installations can not access WSL disk at all and on the newer ones it is still problematic. Thus, create the erlang src/git on /mnt/c//otp/ and don't create links from wsl to windows, that will cause problems for the scripts and will not work. Use: cd /mnt/c//otp eval `./otp_build env_win32 ARCH` ./otp_build To build with emu_cc (32 and 64) it needs mingw-gcc On wsl ubuntu use: 'sudo apt-get install gcc-mingw-w64' to install everything for both build targets. Additional commit comments: - Let configure (crypto/wx) search in '/mnt/c/DocumentedPaths' - Use -Z7 for debug info Add debug info into .o files instead of vc120.pdb which makes parallel compilation more stable. - Use mingw-gcc as emu_cc Packages available in ubuntu. - Use $ERL_TOP/tmp for temporary directories Linux /tmp is not accessable in older wsl (arrived in Win 10 19.03). - Quoting is problematic It seems to be impossible to handle 'spaces' in paths correct, the autotools are just not prepared to handle that and we depend on them. Currently NOT supported but have been prepared for: -Using wsl as disk -- Ensure directory exists If linux file server is overloaded it may take a while until the directory is visible for windows programs. -- Use absolute paths Windows tools needs absolute (the network path) to access files on the wsl drive. Also we can not use mixed mode (forward slashes) for network paths, windows programs don't recognize //wsl$// --- otp_build | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'otp_build') diff --git a/otp_build b/otp_build index 58bf617cf0..ed00a3ed7e 100755 --- a/otp_build +++ b/otp_build @@ -760,6 +760,48 @@ echo_env_msys () echo_envinfo } +echo_env_wsl () +{ + X64=$1 + #echo_envinfo + if [ X"$SHELL" = X"" ]; then + echo "You need to export the shell variable first," \ + "for bourne-like shells, type:" >&2 + echo 'export SHELL' >&2 + echo "and for csh-like shells, type:" >&2 + echo 'setenv SHELL $SHELL' >&2 + echo " - then try again." >&2 + exit 1 + fi + echo_env_erltop + + WIN32_WRAPPER_PATH="$ERL_TOP/erts/etc/win32/wsl_tools/vc:$ERL_TOP/erts/etc/win32/wsl_tools" + + echo_setenv OVERRIDE_TARGET win32 ';' + if [ X"$X64" = X"true" ]; then + echo_setenv CONFIG_SUBTYPE win64 ';' + fi + echo_setenv WSLcross true ';' + echo_setenv CC cc.sh ';' + echo_setenv CXX cc.sh ';' + echo_setenv AR ar.sh ';' + echo_setenv RANLIB true ';' + if [ X"$X64" = X"true" ]; then + if [ -f "$ERL_TOP/erts/autoconf/win64.config.cache.static" ]; then + echo_setenv OVERRIDE_CONFIG_CACHE_STATIC "$ERL_TOP/erts/autoconf/win64.config.cache.static" ';' + fi + echo_setenv OVERRIDE_CONFIG_CACHE "$ERL_TOP/erts/autoconf/win64.config.cache" ';' + else + if [ -f "$ERL_TOP/erts/autoconf/win32.config.cache.static" ]; then + echo_setenv OVERRIDE_CONFIG_CACHE_STATIC "$ERL_TOP/erts/autoconf/win32.config.cache.static" ';' + fi + echo_setenv OVERRIDE_CONFIG_CACHE "$ERL_TOP/erts/autoconf/win32.config.cache" ';' + fi + echo_setenv WIN32_WRAPPER_PATH "$WIN32_WRAPPER_PATH" ';' + echo_setenv PATH "$WIN32_WRAPPER_PATH:$PATH" ';' + echo_envinfo +} + lookup_prog_in_path () { PROG=$1 @@ -1162,7 +1204,9 @@ case "$1" in if [ x"$2" = x"x64" -o x"$2" = x"amd64" ]; then ISX64=true fi - if [ -x /usr/bin/msys-?.0.dll ]; then + if [ -x /bin/wslpath ]; then + echo_env_wsl $ISX64 + elif [ -x /usr/bin/msys-?.0.dll ]; then echo_env_msys $ISX64 else echo_env_cygwin $ISX64 @@ -1170,7 +1214,9 @@ case "$1" in env_mingw32) echo_env_mingw32;; env_win64) - if [ -x /usr/bin/msys-?.0.dll ]; then + if [ -x /bin/wslpath ]; then + echo_env_wsl true + elif [ -x /usr/bin/msys-?.0.dll ]; then echo_env_msys true else echo_env_cygwin true -- cgit v1.2.1 From 73d3d02d887408e99489a9df3877dd409021cc82 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Mon, 11 Nov 2019 15:43:49 +0100 Subject: Setup VC env in otp_build If there is no cl.exe in path try to setup the paths and the needed env variables. Use vcvarsall.bat from VC so we get the correct path and libraries. Search some default installations paths --- otp_build | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'otp_build') diff --git a/otp_build b/otp_build index ed00a3ed7e..8d9854614e 100755 --- a/otp_build +++ b/otp_build @@ -777,6 +777,13 @@ echo_env_wsl () WIN32_WRAPPER_PATH="$ERL_TOP/erts/etc/win32/wsl_tools/vc:$ERL_TOP/erts/etc/win32/wsl_tools" + if [ ! -n "`lookup_prog_in_path cl`" ]; then + if [ X"$X64" = X"true" ]; then + setup_win32_cl_env "x64" `wslpath -a -m erts/etc/win32/wsl_tools/SetupWSLcross.bat` + else + setup_win32_cl_env "x86" `wslpath -a -m erts/etc/win32/wsl_tools/SetupWSLcross.bat` + fi + fi echo_setenv OVERRIDE_TARGET win32 ';' if [ X"$X64" = X"true" ]; then echo_setenv CONFIG_SUBTYPE win64 ';' @@ -802,6 +809,17 @@ echo_env_wsl () echo_envinfo } + +setup_win32_cl_env () +{ + eval `cmd.exe /c $2 $1` + echo_setenv INCLUDE "$INCLUDE" ';' + echo_setenv LIB "$LIB" ';' + echo_setenv LIBPATH "$LIBPATH" ';' + echo_setenv VCToolsRedistDir "$VCToolsRedistDir" ';' + echo_setenv WSLENV "$WSLENV" ';' +} + lookup_prog_in_path () { PROG=$1 @@ -1092,8 +1110,13 @@ case $TARGET in 'the command' exit 1 fi;; - *) - ;; + *) + if [ -x /bin/wslpath -a X"$OVERRIDE_TARGET" = X"" \ + -a X"$1" != X"env_win32" -a X"$1" != X"env_msys32" -a X"$1" != X"env_msys64" ]; then + echo "Building linux binary; if you intended to cross build for win32 use" >&2 + echo ' eval `./otp_build env_win32`\n' >&2 + fi + ;; esac if [ ! -z "$OVERRIDE_TARGET" ]; then -- cgit v1.2.1