Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set FLEXDIR when bootstrapping flexlink #13723

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Jan 9, 2025

Follow-up to #13494. When linking, flexlink needs one of its system-specific support objects (e.g. flexdll_mingw64.o). When flexlink.exe is bootstrapped with OCaml, these objects are installed in %PREFIX%\lib\ocaml\flexdll and the compiler automatically adds -I +flexdll. During the build, however, we currently rely on flexlink's historical default, which is to look for these objects in Filename.dirname Sys.executable_name. In the build, this just means the objects get copied to both byte/bin/ and opt/bin/ and it Just Works™ (full mechanism described in #12278). However, opt/bin/flexlink.exe is now capable of being a symlink to ../../flexlink.opt.exe, and the root directory doesn't contain the objects.

This PR simplifies things by instead setting the FLEXDIR environment variable (which, if set, is used by flexlink instead of Filename.dirname Sys.executable_name). That change is fairly simple - it's made slightly more complicated by cross-compilation, since the root directory path has to be run via cygpath, but only if we're building on MSYS2 / Cygwin.

Previously, the flexdll support objects were placed in both byte/bin and
opt/bin with the copy of flexlink.exe when flexlink was being
bootstrapped with OCaml. The objects are small, so the copying was not
particulary onerous.

However, if opt/bin/flexlink.exe is a native Windows symlink (pointing
to ../../flexlink.opt.exe) then Sys.executable_name when flexlink runs
will point to the wrong place. While flexlink ought to be checking
Sys.argv.(0) rather than Sys.executable_name, a better hardening is to
be explicit and set the FLEXDIR environment variable to point to the
directory containing the support objects. This also allows
byte/bin/flexlink.exe and opt/bin/flexlink.exe to share the same copy of
the objects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant