richfelker / musl-cross-make

Simple makefile-based build for musl cross compiler
MIT License
1.29k stars 266 forks source link

allow specifying extra patch directory #143

Closed hertrste closed 7 months ago

hertrste commented 2 years ago

This commit allows the user to specify an extra patch directory by either placing EXTRA_PATCHES in the config.mak or as an environment variable when invoking make.

The patch directory is expected to have the same structure as the patches/ directory, thus having subdirectories with the respective components (gcc, musl, ...) and their version.

Providing EXTRA_PATCHES is optional.

Having extra patches allows to specify custom MUSL patches without dirtying the musl-cross-make repository directory.

richfelker commented 2 years ago

I like this idea, but I have one concern and I don't know if there's a good way to improve it. Most things you can set in config.mak or on the make command line can be per-build, with multiple targets under the same top-level mcm tree, and don't have stateful side effects outside that. However, as written, the EXTRA_PATCHES apply when the (shared) patched source trees are setup under the top-level mcm dir, and thereby affect later builds in the same dir even if it's no longer used, or fail to affect anything if the sources were already extracted.

There are 2 possible ways I can think of we might go about improving this:

  1. Some sort of stamp file recording the value of EXTRA_PATCHES and dependency information so that the patched source trees get rebuilt if it changed. But I'm bad at making these and they're kinda hacks and I'm not sure if they'd risk causing large amounts of stuff to get rebuilt gratitously by mistake.
  2. Moving the patched source trees under the build directories, which is practical now that we use cowpatch. I've actually been meaning to do this for a while. Then EXTRA_PATCHES could be recorded in the generated BUILD_DIR config.mak file, with the intent that you not poke at it after generation.

Any thoughts on this?