ocaml / flexdll

a dlopen-like API for Windows
Other
97 stars 30 forks source link

Cosmetic updates #110

Closed dra27 closed 1 year ago

dra27 commented 1 year ago
nojb commented 1 year ago

Hello @dra27! I just saw this PR fly past and thought I would take advantage of it to pose an unrelated question. We maintain the following diff for one of our clients (who builds OCaml from source, with the "boostrapped" FlexDLL):

diff --git a/mlfi/ocaml/flexdll/Makefile b/mlfi/ocaml/flexdll/Makefile
--- a/mlfi/ocaml/flexdll/Makefile
+++ b/mlfi/ocaml/flexdll/Makefile
@@ -161,7 +161,7 @@ Compat.ml: COMPILER-$(COMPAT_VERSION) $(addsuffix .ml, $(COMPAT_MODULES))
 flexlink.exe: $(OBJS) $(RES)
        @echo Building flexlink.exe with TOOLCHAIN=$(TOOLCHAIN) for OCaml $(OCAML_VERSION)
        rm -f flexlink.exe
-       $(RES_PREFIX) $(OCAMLOPT) -o flexlink.exe $(LINKFLAGS) $(OBJS)
+       FLEXLINKFLAGS="" $(RES_PREFIX) $(OCAMLOPT) -o flexlink.exe $(LINKFLAGS) $(OBJS)

 version.res: version.rc
        $(RES_PREFIX) rc version.rc

The point is that they set FLEXLINKFLAGS to pass some flags to flexlink when building the compiler (if memory serves, it is -link <resource file> to add icons and copyright information to the built objects), but this variable should be unset when building flexlink itself. As far as I can see there is no way to do this from "outside" the build system. Does it make sense? Do you see how to achieve this, or a better way to go about it?

dra27 commented 1 year ago

🙂 I agree that can't easily be done from outside. The patch could be done in the compiler's build system, which I'm guessing might simplify things, as I presume the compiler is patched, but flexdll is otherwise unpatched? In the compiler's root Makefile, there's FLEXLINK_BUILD_ENV and I think that adding FLEXLINKFLAGS= to that should have the desired effect. That might not work with without an export in there somewhere - in which case the alternative would be to change the recipes for boot/flexlink.byte$(EXE) and flexlink.opt$(EXE) directly so that FLEXLINKFLAGS= appears before recursive make invocation (i.e. the difference between a shell variable set in a command vs a make variable being exported to commands).

nojb commented 1 year ago

🙂 I agree that can't easily be done from outside.

Thanks for the explanation!