ivpri has asked for the wisdom of the Perl Monks concerning the following question:

Hello! I am trying to compile perl on Windows to have a single distribution archive for both 32 and 64 bit. So, in the GNUmakefile this is exactly what I need, I have uncommented it:
# # Comment this out if you DON'T want your perl installation to have # architecture specific components. This means that architecture- # specific files will be installed along with the architecture-neutral # files. Leaving it enabled is safer and more flexible, in case you # want to build multiple flavors of perl and install them together in # the same location. Commenting it out gives you a simpler # installation that is easier to understand for beginners. # INST_ARCH := \$(ARCHNAME)
Well, seems easy, but compilation fails strangly:
Z:\perl\perl-5.30.1\win32>gmake -j2 INST_TOP=C:\perl CCHOME="c:\Progra +m Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64" # CCTYPE=GCC # GCCBIN=gcc # GCCVER=8.1.0 # GCCTARGET=x86_64-w64-mingw32 # GCCCROSS= # WIN64=define # ARCHITECTURE=x64 # ARCHNAME=MSWin32-x64-multi-thread # MAKE=gmake if not exist "mini" mkdir "mini" g++ -I.\include -I. -I.. -DWIN32 -DWIN64 -DCONSERVATIVE -DPERLDLL -DP +ERL_CORE -s -O2 -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPE +RL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfie +lds -o..\generate_uudmap.exe ..\generate_uudmap.c \ -s -L"C:\perl\lib\\CORE" -L"c:\Program Files\mingw-w64\x86_64-8.1.0-p +osix-seh-rt_v6-rev0\mingw64\lib" -lmoldname -lkernel32 -luser32 -lgd +i32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -ln +etapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 - +lcomctl32 copy config_H.gc config.h 1 file(s) copied. ... DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL -omini\globals.o ..\globals.c g++ -mconsole -o ..\miniperl.exe -s -L"C:\perl\lib\\CORE" -L"c:\Progr +am Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib" min +i\toke.o mini\regcomp.o mini\regexec.o mini\op.o mini\sv.o mini\pp.o +mini\pp_ctl.o mini\pp_sys.o mini\pp_pack.o mini\pp_hot.o mini\gv.o mi +ni\perl.o mini\utf8.o mini\dump.o mini\hv.o mini\av.o mini\caretx.o m +ini\deb.o mini\doio.o mini\doop.o mini\dquote.o mini\globals.o mini\m +ro_core.o mini\locale.o mini\keywords.o mini\mathoms.o mini\mg.o mini +\numeric.o mini\pad.o mini\perlapi.o mini\perly.o mini\pp_sort.o mini +\reentr.o mini\run.o mini\scope.o mini\taint.o mini\time64.o mini\uni +versal.o mini\util.o mini\miniperlmain.o mini\perlio.o mini\win32.o m +ini\win32sck.o mini\win32thread.o mini\fcrypt.o mini\win32io.o -lmol +dname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -l +shell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm - +lversion -lodbc32 -lodbccp32 -lcomctl32 ..\miniperl.exe -I..\lib -f ..\write_buildcustomize.pl .. ..\miniperl.exe -I..\lib config_sh.PL "INST_TOP=C:\perl" "INST_VER=" " +INST_ARCH=\" "archname=MSWin32-x64-multi-thread" "cc=gcc" "ld=g++" "c +cflags= -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPT +S -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -f +no-strict-aliasing -mms-bitfields" "usecplusplus=" "cf_email=" "d_mym +alloc=undef" "libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool + -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid + -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32" "in +cpath=c:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mi +ngw64\include" "libperl=libperl530.a" "libpth=c:\Program Files\mingw- +w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib;" "libc=" "make=gma +ke" "_o=.o" "obj_ext=.o" "_a=.a" "lib_ext=.a" "static_ext=Win32CORE" +"usethreads=define" "useithreads=define" "usemultiplicity=define" "us +eperlio=define" "use64bitint=define" "uselongdouble=undef" "uselargef +iles=define" "usesitecustomize=undef" "default_inc_excludes_dot=defin +e" "LINK_FLAGS=-s -L\"C:\perl\lib\\CORE\" -L\"c:\Program Files\mingw- +w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib\"" "optimize=-s -O2 +" "ARCHPREFIX=" "WIN64=define" config.gc > ..\config.sh ..\miniperl.exe -I..\lib ..\make_patchnum.pl Updating 'git_version.h' and 'lib/Config_git.pl' Use of uninitialized value $opt{"static_ext"} in split at config_sh.PL + line 51. Use of uninitialized value $opt{"d_mymalloc"} in string eq at config_s +h.PL line 107. Use of uninitialized value $opt{"cc"} in pattern match (m//) at config +_sh.PL line 113. Use of uninitialized value $opt{"cc"} in pattern match (m//) at config +_sh.PL line 116. Use of uninitialized value $opt{"uselargefiles"} in string eq at confi +g_sh.PL line 121. Use of uninitialized value $opt{"WIN64"} in string eq at config_sh.PL +line 131. Use of uninitialized value $opt{"use64bitint"} in string eq at config_ +sh.PL line 151. Use of uninitialized value $opt{"cc"} in pattern match (m//) at config +_sh.PL line 196. Use of uninitialized value $opt{"WIN64"} in string eq at config_sh.PL +line 197. Use of uninitialized value $opt{"uselongdouble"} in string eq at confi +g_sh.PL line 210. Use of uninitialized value $opt{"cc"} in pattern match (m//) at config +_sh.PL line 239. Use of uninitialized value $opt{"cc"} in pattern match (m//) at config +_sh.PL line 263. Use of uninitialized value $opt{"cc"} in pattern match (m//) at config +_sh.PL line 284. Use of uninitialized value $opt{"useithreads"} in string eq at config_ +sh.PL line 304. Use of uninitialized value $opt{"usecplusplus"} in string eq at config +_sh.PL line 308. Can't open -s: No such file or directory at config_sh.PL line 315. Can't open -O2: No such file or directory at config_sh.PL line 315. Can't open -DWIN32: No such file or directory at config_sh.PL line 315 +. Can't open -DWIN64: No such file or directory at config_sh.PL line 315 +. Can't open -DCONSERVATIVE: No such file or directory at config_sh.PL l +ine 315. Can't open -DPERL_TEXTMODE_SCRIPTS: No such file or directory at confi +g_sh.PL line 315. Can't open -DPERL_IMPLICIT_CONTEXT: No such file or directory at confi +g_sh.PL line 315. Can't open -DPERL_IMPLICIT_SYS: No such file or directory at config_sh +.PL line 315. Can't open -DUSE_PERLIO: No such file or directory at config_sh.PL lin +e 315. Can't open -fwrapv: No such file or directory at config_sh.PL line 315 +. Can't open -fno-strict-aliasing: No such file or directory at config_s +h.PL line 315. Can't open -mms-bitfields usecplusplus= cf_email= d_mymalloc=undef lib +s=: No such file or directory at config_sh.PL line 315. Can't open -lmoldname: No such file or directory at config_sh.PL line +315. Can't open -lkernel32: No such file or directory at config_sh.PL line +315. Can't open -luser32: No such file or directory at config_sh.PL line 31 +5. Can't open -lgdi32: No such file or directory at config_sh.PL line 315 +. Can't open -lwinspool: No such file or directory at config_sh.PL line +315. Can't open -lcomdlg32: No such file or directory at config_sh.PL line +315. Can't open -ladvapi32: No such file or directory at config_sh.PL line +315. Can't open -lshell32: No such file or directory at config_sh.PL line 3 +15. Can't open -lole32: No such file or directory at config_sh.PL line 315 +. Can't open -loleaut32: No such file or directory at config_sh.PL line +315. Can't open -lnetapi32: No such file or directory at config_sh.PL line +315. Can't open -luuid: No such file or directory at config_sh.PL line 315. Can't open -lws2_32: No such file or directory at config_sh.PL line 31 +5. Can't open -lmpr: No such file or directory at config_sh.PL line 315. Can't open -lwinmm: No such file or directory at config_sh.PL line 315 +. Can't open -lversion: No such file or directory at config_sh.PL line 3 +15. Can't open -lodbc32: No such file or directory at config_sh.PL line 31 +5. Can't open -lodbccp32: No such file or directory at config_sh.PL line +315. Can't open -lcomctl32 incpath=c:\Program: No such file or directory at + config_sh.PL line 315. Can't open Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\i +nclude libperl=libperl530.a libpth=c:\Program: No such file or direct +ory at config_sh.PL line 315. Can't open Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\l +ib; libc= make=gmake _o=.o obj_ext=.o _a=.a lib_ext=.a static_ext=Win +32CORE usethreads=define useithreads=define usemultiplicity=define us +eperlio=define use64bitint=define uselongdouble=undef uselargefiles=d +efine usesitecustomize=undef default_inc_excludes_dot=define LINK_FLA +GS=-s: No such file or directory at config_sh.PL line 315. Can't open -L"C:\perl\lib\\CORE": Invalid argument at config_sh.PL lin +e 315. Can't open -L"c:\Program: No such file or directory at config_sh.PL li +ne 315. Can't open Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\l +ib" optimize=-s: Invalid argument at config_sh.PL line 315. Can't open -O2 ARCHPREFIX= WIN64=define config.gc : No such file or di +rectory at config_sh.PL line 315. ..\miniperl.exe -I..\lib ..\configpm --chdir=.. Use of uninitialized value $t in string eq at ..\configpm line 345. Use of uninitialized value $s in numeric eq (==) at ..\configpm line 3 +45. Use of uninitialized value $s in numeric eq (==) at ..\configpm line 3 +48. Use of uninitialized value $s in numeric eq (==) at ..\configpm line 3 +48. Use of uninitialized value $s in concatenation (.) or string at ..\con +figpm line 358. Use of uninitialized value in pattern match (m//) at ..\configpm line +428. Use of uninitialized value $osname in string eq at ..\configpm line 46 +1. Use of uninitialized value $osname in string eq at ..\configpm line 46 +2. Use of uninitialized value $osname in sprintf at ..\configpm line 465. Use of uninitialized value $osname in sprintf at ..\configpm line 465. Use of uninitialized value $osname in sprintf at ..\configpm line 465. written lib/Config.pod updated lib/Config.pm updated lib/Config_heavy.pl syntax error at lib/Config_heavy.pl line 166, near "x;" Compilation failed in require at ..\configpm line 1146. gmake: *** [GNUmakefile:1314: ..\lib\Config.pm] Error 255
Of course, I have tried to comment it back, gmake clean, then compile like above, everything works then. Also, I have tried to set INST_ARCH to something different from $(ARCHNAME). Everything compiled and installed successfully but after that the @INC is empty:
gmake clean gmake -j2 INST_TOP=C:\perl CCHOME="c:\Program Files\mingw-w64\x86_64-8 +.1.0-posix-seh-rt_v6-rev0\mingw64" INST_ARCH=\x64 gmake install c:\perl\bin\x64\perl -V Can't locate Config.pm in @INC (you may need to install the Config mod +ule) (@INC contains:). BEGIN failed--compilation aborted.
Any idea how to have it working with INST_ARCH set?

Replies are listed 'Best First'.
Re: Perl compilation on Windows with INST_ARCH set fails
by syphilis (Bishop) on Jan 25, 2020 at 00:42 UTC
    Any idea how to have it working with INST_ARCH set?

    I'm seeing the same as you. It's buggy.
    I suspect that the escaping of $(ARCHNAME) is incorrect, and that the backslash needs to be removed:
    INST_ARCH := $(ARCHNAME)
    At least it will then build current blead (perl-5.31.7). But it seems to produce the same structure as a perl built without INST_ARCH.
    So I then additionally tried supplying it with the archname that needs to be used for the particular build I was doing - ie ARCHNAME=MSWin32-x64-multi-thread But that just resulted in an installation whose top level directory structure was quite bizarre:
    bin binMSWin32-x64-multi-thread html lib libMSWin32-x64-multi-thread site
    and an empty @INC (as you noted).
    So ... there's a bit to unravel, and the suggestion of building with dmake and makefile.mk looks the best short term option.

    Cheers,
    Rob

      Backslash does not escape variable expansion in GNU make; doubling the sigil does that ("$${XYZ}" reduces to "${XYZ}"). That backslash is a directory separator.

        Backslash does not escape variable expansion in GNU make

        Heh ... at last I understand the reason that they're called "makefiles".
        (They're the "files" that "make" me look stupid ;-)

        Cheers,
        Rob
Re: Perl compilation on Windows with INST_ARCH set fails
by jcb (Curate) on Jan 25, 2020 at 00:57 UTC

    There is an error in that Makefile. That is a "simply expanded" assignment instead of a "recursively expanded" assignment. Try changing that line to:

    INST_ARCH = \$(ARCHNAME)

    It seems that ARCHNAME is not set at the time that line is read; changing it to a recursively expanded assignment should avoid the problem by expanding $(ARCHNAME) when INST_ARCH is substituted instead of when it is defined.

    Your problem could also be that ARCHNAME is somehow getting set to the empty string, which is also wrong. You may want to submit a bug report when you find the solution to this; it seems to me that building on Windows is subtly broken at the moment.

      INST_ARCH    = \$(ARCHNAME)

      That change alone seems to fix the problem for me.
      Alternatively, I can leave the GNUmakefile in it's original state and pass INST_ARCH=\MSWin32-x64-multi-thread as one of the arguments passed to 'make'.
      Both result in a perl whose @INC is:
      INST_TOP/site/lib/MSWin32-x64-multi-thread INST_TOP/site/lib INST_TOP/lib/MSWin32-x64-multi-thread INST_TOP/lib
      Also existent is:
      INST_TOP/bin INST_TOP/bin/MSWin32-x64-multi-thread
      I'm not entirely sure what an archnamed build should look like - but the build I've got feels right and looks sane.
      I haven't tried specifying an INST_ARCH value that doesn't match $Config{archname}. (Not sure what to expect with that.)

      I think I might even start building my perls this way.

      Normally, for every version of perl that I build, I have 4 different configurations (ie 4 different archnames).
      Building them with INST_ARCH into the same INST_TOP would make good sense and reduce duplication.

      Thanks for chiming in jcb.
      It's a pity you didn't get in there a bit earlier. (Would have saved me some time, effort and embarrassment ;-)

      Cheers,
      Rob
Re: Perl compilation on Windows with INST_ARCH set fails
by Anonymous Monk on Jan 24, 2020 at 21:08 UTC
    When I did it i used  dmake -f makefile.mk  
Re: Perl compilation on Windows with INST_ARCH set fails
by Anonymous Monk on Jan 24, 2020 at 22:24 UTC
    This seems wrong in an obvious way

    How did you get  "INST_ARCH=\"  ? The only way I can see is by passing  INST_ARCH=\

    I suggest you turn this on by editing GNUmakefile like you're supposed to