summaryrefslogtreecommitdiff
path: root/mk/wrapper
AgeCommit message (Collapse)AuthorFilesLines
2022-04-04mk: Cross-eyed hacks to support cross-libtool.riastradh1-4/+4
For a long time, when cross-building, say from native=amd64 to target=powerpc, it was necessary to: 1. cross-build a _powerpc_ package called cross-libtool-base-powerpc, and then 2. install the powerpc package _natively_ with `pkg_add -m x86_64' to override the architecture check that normally forbids this kind of shenanigans, in order to cross-build anything that uses libtool as a tool. This is partly because libtool doesn't follow the normal GNU convention of `./configure --build=<native platform> --host=<platform package will run on> --target=<platform package is configured to operate on>' -- in this example, build=amd64, host=amd64, target=powerpc. Instead, libtool expects to be cross-built itself, even if it's going to run as a tool. It's not as bonkers as it sounds at first: libtool is just a shell script, and it caches various information about the (cross-building!) toolchain it is built with so it can use that information later when it is run as a tool itself to cross-compile other software. To make this work, we need to create the toolchain wrappers for libtool _as if_ we were cross-building even if we are building a native package. So mk/tools uses a new flag TOOLS_USE_CROSS_COMPILE instead of USE_CROSS_COMPILE, and libtool internally sets MACHINE_ARCH=${TARGET_ARCH} (in the example above, powerpc) to make it look like we're cross-building. The new TOOLS_CROSS_DESTDIR is an alias for the (defaulted) CROSS_DESTDIR, which must now be set unconditionally in mk.conf in order for libtool to know where the cross-destdir will be; _CROSS_DESTDIR remains empty when building any native packages (including the native cross-libtool package). Finally, we need to make the resulting package be a native package, with MACHINE_ARCH set to the one that it will be installed on (in the example above, amd64), so I added an indirection _BUILD_DEFS.${var} to replace var on its own in the build definitions that get baked into the package, shown by `pkg_info -B'. Setting _BUILD_DEFS.MACHINE_ARCH=${NATIVE_MACHINE_ARCH} ensures that this mutant hybrid cross-built libtool still produces a native package. All of this logic is gated on setting USE_CROSS_COMPILE in mk.conf or LIBTOOL_CROSS_COMPILE in the package makefile, so it should be safe for non-cross-builds -- when USE_CROSS_COMPILE=no and you're not building cross-libtool, everything is as before.
2022-03-13mk: MKPIE is not GCC-specific. Should help ObjC packages.nia1-2/+2
2022-01-18Add a package-settable variable PKGSRC_OVERRIDE_MKPIEpho1-2/+2
This is needed by packages that require hand-holding in building PIE. Also a post-build check for MKPIE is performed by default when PKG_DEVELOPER=YES.
2021-06-25switch $echo statements to printf "%s\n".maya1-30/+29
dash considers \1 to be octal escape. for PR pkg/56248, from Michael Forney's suggestion. $echo seems to be used for performance here (was previously cat) and not for compatibility with some esoteric system. I misunderstood things, and failed to test the last bootstrap diff, breaking bootstrap on Ubuntu for a while.
2020-05-02mk/wrapper/transform-gcc: pass -Wno-* without warningrillig1-15/+2
Seen in lang/mono6.
2020-04-27mk/wrapper: allow "unwrap" to be a no-op SUBST blockrillig1-1/+2
Discovered in pkgtools/pkg, where libpkg/pkg.pc was left unmodified.
2020-03-22mk/wrapper/transform-gcc: pass -Werror=* without warningrillig1-1/+2
2019-05-07mk: allow "bmake clean depends" as shortcutrillig1-4/+4
When "bmake clean depends" was called for a package where the various cookie files already existed, these would enable different rules than a clean package directory. Since "bmake clean" deletes all the cookie files before "bmake depends" starts, in these combined command lines the cookie files must be treated as absent.
2018-11-20Add a rule for -Wp,-MD, which isn't provided by MIPSPro.maya1-1/+2
MDupdate is the equivalent. From duck in PR pkg/48424.
2018-08-22Remove clauses 3,4 from TNF-only copyright blocks.maya30-240/+30
This is based on the decision The NetBSD Foundation made in 2008 to do so, which was already applied to src. This change has been applied to code which is likely not in other repositories. ok board@, reviewed by riastradh@
2018-06-19Disable the flags for PKGSRC_MKPIE when explicitly requiredkhorben1-1/+6
This notably allows emulators/qemu to properly detect support for PIE, and disable it where appropriate. This does not work with cwrappers yet.
2017-11-16Really use the parent sink for ld(1)khorben1-2/+2
2017-11-16Introduce a command sink for ld(1) with MKPIEkhorben2-1/+41
When not using cwrappers, so far PKGSRC_MKPIE was only automatically applied when linking using gcc(1) (when enabled). This is now also the case for packages using ld(1) to link executables.
2017-11-16Recognize more situations where not linking executableskhorben1-2/+2
This is only relevant for PKGSRC_MKPIE. It partly reflects a fix that was committed to the cwrappers for MKPIE, where the "-pie" flag was automatically added in spite of the linker not actually creating an executable.
2017-11-16Obtain the MKPIE flags from the environmentkhorben2-5/+9
This solves an issue with the command sink component of the MKPIE wrapper for GCC, where the contents of the _MKPIE_CFLAGS.gcc and _MKPIE_LDFLAGS.gcc variables was guessed. It is now communicated to cmd-sink-mkpie-gcc through the environment instead.
2017-11-16Let the MKPIE command sink for GCC re-use the generic command sinkkhorben1-10/+2
The cmd-sink-mkpie-gcc component for PKGSRC_MKPIE support on GCC was lagging behind the generic one. This makes sure it cannot happen again, by invoking the generic sink right away.
2017-04-16More consistent log outputkhorben1-2/+2
2016-09-16Allow '-l m' like '-lm' and update the comment for -l and -Dryoon1-3/+4
O.k. by jperkin@ and dholland@
2016-03-14Add support for -isystem to legacy wrappers.markd4-4/+35
rewrite "-isystem dir" as "-isystem,dir" transform "-isystem,dir" in same ways as "-Idir" rewrite "-isystem,dir" back to "-isystem dir" in cmd-sink
2016-03-13Also determine when compiling from source fileskhorben2-4/+16
This allows fixing an issue with PKGSRC_MKPIE, where "gcc source.c" would not work. Some packages rely on this test to determine if a working compiler is available.
2016-03-12Also register "-pie" as a known argument for gcc(1)khorben1-1/+2
As suggested by wiz@
2016-03-11Add support for a number of security featureskhorben4-3/+69
- Revisit (and rename) support for FORTIFY as PKGSRC_USE_FORTIFY (instead of PKGSRC_USE_FORT) for easier support outside NetBSD/gcc; - PKGSRC_USE_SSP is no longer enabled by default when PKGSRC_USE_FORTIFY is enabled; - PKGSRC_MKPIE builds executables as PIE (to leverage userland ASLR) - PKGSRC_USE_RELRO builds with a read-only GOT to prevent some exploits from functioning. Tested on NetBSD/amd64 by myself, in every combination, with and without pkgtools/cwrappers. MKPIE is not supported at the moment with cwrappers. Also, MKPIE is known to still break a number of packages when enabled (and actually supported). Tested on SunOS by jperkin@, thank you! As discussed on tech-pkg@, the default behavior is not changed, except where noted above. ok bsiegert@
2016-03-04pass correct ABI via OBJECT_MODE environment variable on AIXtnn2-52/+1
It turns out a handful of AIX binutil-like utilities are particular about type of object files they should examine. Instead of piping through flags for each utility everywhere, it is easier to just export 'OBJECT_MODE=[32|64]' instead. From Eric N. Vander Weele.
2016-03-04pass correct ABI flags to ar(1) on AIXtnn2-1/+52
AIX is particular about the type of object files `ar` should examine. This should be set explicitly to coincide with the user's defined $ABI. Contributed by Eric N. Vander Weele.
2016-01-31Fixed subst.mk not to corrupt filesrillig1-2/+2
Up to now, using subst.mk may have led to file corruption during active package development. This happened when a sed(1) command had a syntax error, in which case the whole sed(1) command was terminated, leaving an empty original file behind. This commit changes that behavior by applying the sed(1) commands to the original file and saving the result in a temporary file. Only after that succeeded is the original file overwritten. During this rewrite, SUBST_POSTCMD has been removed, since it was only used in one place (mk/wrapper), and since it relied on the exact sequence of the internal commands. No package in either main pkgsrc or pkgsrc-wip uses this variable right now.
2015-11-20PR pkg/47404richard1-3/+5
wrapper should convert '--rpath' to '-rpath', fixing pysvn as well as many other packages inadvertently using double-dash form of rpath.
2015-04-29Introduce _USE_CWRAPPERS logic to ensure consistency, USE_CWRAPPERS couldjperkin1-2/+2
differ between a package and user setting, resulting in incorrect WRAPPER_* values being set from wrapper-defs.mk.
2015-04-28Move cwrappers WRAPPER_DIR and WRAPPER_BINDIR to wrapper-defs.mk, it isjperkin1-1/+6
included by bsd.prefs.mk so we need to ensure consistency.
2015-04-27Split cwrappers from legacy wrappers. We no longer generate the legacyjperkin1-3/+1
wrappers when USE_CWRAPPERS is enabled, saving a reasonable amount of I/O during builds, mostly due to avoiding the transform/untransform sed file generations. WRAPPER_DIR and WRAPPER_BINDIR are used by various packages to override or point to specific wrappers, and these now point to the cwrappers directory when enabled, removing the need for CWRAPPERS_BIN_DIR duplication and fixing packages which previously were using legacy wrappers by accident. A number of targets are now duplicated between bsd.wrapper.mk and cwrappers.mk, the intention being that the legacy wrappers will be deprecated once cwrappers is verified on all supported platforms. If that turns out to take longer than expected, we will probably want to introduce a wrapper.mk to abstract them away before loading the appropriate back-end.
2015-04-27Remove ECHO_WRAPPER_MSG and just use ECHO_BUILDLINK_MSG, which was setjperkin1-14/+5
to the same value anyway. Also removes a comment from 2005 which was possibly wrong at the time it was committed, given the same construct has been used in bsd.buildlink3.mk unchanged since 2004.
2015-04-26revert rev. 1.7. Although it should be correct in theory it interactstnn1-3/+2
with the build of some packages in subtle ways, and needs more testing.
2015-04-25Fix typo in comment.wiz1-2/+2
2015-04-25If we have -Wl,--whole-archive -lfoo -lbar -Wl,--no-whole-archivetnn1-2/+3
surrounding a list of static libraries, we must preserve that order so the effect of --whole-archive is as intended by the package. cwrappers does this correctly but classic wrappers didn't.
2014-12-30Remove pkg_views support, second part: infrastructure.wiz1-32/+1
2014-11-25Separate dependency from nada-rule.joerg1-2/+4
2014-11-24Add cwrappers glue as developed during Google's Summer of Code 2007.joerg1-1/+3
2014-09-02Replace calls to cat(1) with echo(1) which is highly likely to be a shelljperkin1-57/+37
builtin. This significantly reduces the number of exec's required during the 'wrapper' phase and brings the execution time down accordingly.
2014-03-06Variable override is confusing.uebayasi1-6/+6
2014-03-06Wrap not only ld but also ar and ranlib.uebayasi1-1/+5
2014-02-26Remove special handling of -v in the wrappers.jperkin1-3/+2
This was originally introduced to work around some behaviour in the libtool build, however these days it is actively harmful for a number of packages, where removing additional arguments when -v is present on the command line can break ABI detection (notably in CMake packages). Instead, filter out any references to BUILDLINK_DIR from the libtool scripts, as that should do the same job. Retain the ability to run the 'scan' wrapper script, as it can be useful in certain cases, and is required to support the scan-libtool script anyway.
2013-12-31Don't try to convert the SunStudio option "-mt". There is no GCC optiontron1-2/+2
which is accepted by both the GCC bundled with Solaris 10 and the more modern GCC versions availabe in "pkgsrc". Handling of POSIX thread related options should be left to pkgsrc anyway. Fix based on a suggestion by Richard Palo.
2013-05-09Use --sysroot in cpp/gcc/gxx cross-compiler wrappers.riastradh3-106/+9
Now that NetBSD supports --sysroot we don't need to mess with the partial measures of -nostdinc, -isystem, &c. ok agc
2013-04-21Fix a harmless typo.uebayasi1-2/+2
2013-03-01Create a wrapper for gfortran.jperkin1-2/+2
2012-07-23Pass through -specs, as used by devel/binutils/override-as.mkjperkin1-1/+5
2012-07-08compiler.mk/gcc.mk: Add support for USE_LANGUAGES+= adamarino1-2/+2
All recent packages featuring Ada code have a hard dependency on the lang/gnat-aux compiler package. The valid values for USE_LANGUAGES are c, c99, c++, fortran, fortran77, java, objc, so specifying a specific compiler was necessary up into now. One problem with lang/gnat-aux is that it is installed at ${LOCALBASE} where the lang/gccXX compilers are installed at ${LOCALBASE}/gccXX. The latter compilers have no possibility of sharing conflicting files unlike lang/gnat-aux. Rather than fundamentally update the GCC 4.6-based lang/gnat-aux to avoid these conflicts, a new Ada-capable compiler based on GCC 4.7 was created with the intent of being supported by mk/compiler.mk and mk/compiler/gcc.mk. The Ada packages will be effectively migrated from lang/gnat-aux to the new lang/gcc-aux compiler, but lang/gcc-aux will remain as a standalone package as it is the only GCC 4.6-based compiler that builds on DragonFly and serves it as a world and kernel compile option. In addition to the current language wrappers, lang/gcc-aux adds wrappers for "ada" (unique to gcc-aux, hardlinked to gcc driver), and the gnat, gnatmake, gnatbind, gnatlink, gnatchop, gnatprep, and gnatls programs. Supporting all of these allows the wrapper system to be used with Ada packages; currently wrappers are mostly disabled on them. The lang/gcc47 implicitly adds support for the "objc-c++" language by adding it to the USE_LANGUAGES list, but it wasn't really supported. An attempt was made to better support objc-c++, but this new enumeration probably still needs work or needs to be removed completely. Logic for Ada support: 1) All lang/gccXX compilers have version numbers ranging from 2.8.1 to 9. 2) lang/gcc-aux uses the release date as its version number in the form of YYYYMMDD with a minimum value of 20120614, so there is no version overlap. 3) When at least one element of USE_LANGUAGES is "ada", the value of 20120614 is added to the set of GCC_REQD which selects lang/gcc-aux. 4) The _NEED_NEWER_GCC check is disabled. It fails and isn't relevant; unless a package sets GCC_REQD over 20120614, the only way to select lang/gcc-aux is to specify the Ada language and only one compiler known to gcc.mk can support it.
2012-06-08Ignore SunPRO -errwarn flags to prevent it from being recognized as a entryobache1-1/+6
point option for `ld'.
2012-04-13Fix typo in comment.wiz1-3/+3
2012-04-13Treat the '--as-needed' and '--no-as-needed' arguments to ld as ifsbd1-2/+7
thay are librarys so that they still surround the given library. WARNING: this may not work if the wrapper reorders librarys.
2012-03-07Rewrite any -R<dir> into -Wl,-R<dir>. -R is the old form of -Wl,-R,he1-1/+7
but our gcc re-orders them so that all -R args come at the front of the "ld" invocation. This messes up the relative search order, and is at least partly responsible for "the pixman problem" experienced on (at least) NetBSD 5.1. This is as close as a general fix as I can think of, and should fix PR#46130, although it possibly doesn't fix every instance of this more general problem.