Perl-Toolchain-Gang / ExtUtils-MakeMaker

Perl module to make Makefiles and build modules (what backs Makefile.PL)
https://metacpan.org/release/ExtUtils-MakeMaker
64 stars 76 forks source link

OBJECT values in subdirs are created in the base dir #400

Open FGasper opened 3 years ago

FGasper commented 3 years ago

If I do:

WriteMakefile(
    # …
    OBJECT => [ 'foo/bar.o' ],
);

… then bar.o gets created in the base dir, not in foo/.

Note that this does compile foo/bar.c; it just doesn’t put the object file where it is meant to go.

This seems like pretty undesirable behaviour. It seems like it should be either fixed (i.e., put the object file where I said to put it) or at least documented.

If necessary, maybe make the fixed version an opt-in affair?

FGasper commented 3 years ago

The workaround that alh found in #xs is: CCFLAGS => "$Config{ccflags} -o \$@".

mohawk2 commented 3 years ago

I don't think there's a good fix that would be backwards-compatible, since this is very long-standing behaviour across many C compilers.

FGasper commented 3 years ago

@mohawk2 What if an enum-string were added, like:

OBJECTFILEMODE => 'givendir',   # default = 'basedir'

That way authors can adopt the new/fixed behaviour, and nothing will disrupt existing projects.

Leont commented 3 years ago

To be honest, this general area of MakeMaker has proven to be so fragile that I'm worried about any such change causing a lot of breakage.

Having some more compilation infrastructure so we can do this sort of thing in an extension would probably be safer.

FGasper commented 3 years ago

If (as I kind of expected) there’s this much aversion to touching the relevant code paths, it’s maybe best just to document the quirk.

mohawk2 commented 2 years ago

Docs would probably be a good idea. Something else to try would be XSMULTI/XSBUILD since I expect any OBJECT will be intended for XS usage.