diff --git a/lang/perl/Makefile b/lang/perl/Makefile index 6a6dd5ea8..6ad27818e 100644 --- a/lang/perl/Makefile +++ b/lang/perl/Makefile @@ -92,6 +92,21 @@ endef # Target perl define Build/Configure + # We don't want to pass -Ilib to host perl in the target build (as lib + # contains the target libraries, and files may currently be written + # while being imported in parallel builds). We do however need the + # target versions of the Config modules at the beginning of the include + # path for the build scripts' use. + # + # Create an alternative lib_build directory that will be added to the + # include path instead of lib (using hostperl-wrapper), containing only + # the config modules. + $(INSTALL_DIR) $(PKG_BUILD_DIR)/lib_build + ln -sf ../lib/Config.pm ../lib/Config_heavy.pl ../lib/Config_git.pl $(PKG_BUILD_DIR)/lib_build/ + + install -m0755 files/hostperl-wrapper $(PKG_BUILD_DIR)/hostperl-wrapper + sed -i "s'@HOST_PERL@'$(HOST_PERL_PREFIX)/bin/perl'g" $(PKG_BUILD_DIR)/hostperl-wrapper + $(PERL_CMD) files/perlconfig.pl -Dowrt:target_cc='$(TARGET_CC)' \ -Dowrt:gccversion=$(CONFIG_GCC_VERSION) \ -Dowrt:target_cross='$(TARGET_CROSS)' \ diff --git a/lang/perl/files/base.config b/lang/perl/files/base.config index 7d8b88b20..1cadfc10a 100644 --- a/lang/perl/files/base.config +++ b/lang/perl/files/base.config @@ -650,7 +650,7 @@ hint='recommended' hostcat='cat /etc/hosts' hostgenerate="$owrt:host_perl_prefix/bin/generate_uudmap" hostosname='' -hostperl="$owrt:host_perl_prefix/bin/perl" +hostperl="./hostperl-wrapper" html1dir=' ' html1direxp='' html3dir=' ' diff --git a/lang/perl/files/hostperl-wrapper b/lang/perl/files/hostperl-wrapper new file mode 100644 index 000000000..e31ef1cf8 --- /dev/null +++ b/lang/perl/files/hostperl-wrapper @@ -0,0 +1,14 @@ +#!@HOST_PERL@ + +foreach (@ARGV) { + # Stop parsing options if we encounter a non-option argument or -- + last if $_ eq '--' || $_ !~ m/^-/; + + # Modify first option of the form -Ilib, -I../lib, ... to refer to lib_build instead + if ($_ =~ m@-I(.*/)?lib@) { + $_ .= '_build'; + last; + } +} + +exec '@HOST_PERL@', @ARGV