-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Clarify and fix construction of MKEXE in configure #10413
Conversation
Many thanks for this PR. It's hard to review but I'm pretty sure it was So, really, thank you, David. At the moment I have just one name-related question, about |
Regarding
Suggestion: apply it to ? |
Other question about |
I may have misread you, sorry. I see instances of addprefix in |
Other Would it perhaps be possible to compute it in a more principled way? For |
In the definitions of I do realise it is not this PR which introduced the "problem", but thought |
My last question for this round of review is: is it really necessary that
Will happily approve the PR when all the remarks have been discussed! |
Many thanks for looking at this, @shindere! Some replies just before I start crafting additional commits:
|
Where |
The main thing to note is that I think that what we should be doing at this stage:
|
David Allsopp (2021/07/21 03:18 -0700):
Many thanks for looking at this, @shindere!
Pleasure.
Some replies just before I start crafting additional commits:
- `mkexe_extra_flags` isn't flexlink-specific - it's flags which must
be passed to both the C compiler _and_ flexlink. I don't mind, though
- the idea is that `FLEXLINK_FLAGS` _could_ include another variable
which doesn't go into `MKEXE_VIA_CC`, but it doesn't at the moment.
That said, I think your idea of splitting `mkexe_extra_flags` into a
`-stack` argument and a `-merge-manifest` argument is interesting and
much more principled - I'll have a look at that instead!
Perhaps I was mislead by a comment in `configure.ac` which was
suggesting they were. Sorry. It would be good to make sure the comment
explaining the variable is accurate.
- I have fixed the definitions of `mksharedlib` - the ones which are
`$CC` are in single quotes, so the $` doesn't need escaping. The
only definition of `mksharedlib` in double-quotes is the one for
`*-apple-darwin*` because the string is long so I had to escape the
newline (and therefore the `\$` as well)
Thanks. I'm wondering: shouldn't we make them alll uniform? If
double-quotes are needed for darwin, why not use the same style
everywhere just for consistency, kind of?
- in `utils/config.mlp`, the machinery there is allowing a different
flexlink binary to be substituted in using the `OCAML_FLEXLINK`
environment variable (this machinery has been there since the
bootstrap was added in 4.03). The `-maindll` occurs in the same way
as `-exe` does, therefore: it controls which of flexlink's three
modes it's going to do. I think it's OK that it knows the parameters
that flexlink takes (in the same way as it's building the `-chain`
argument). It could be done by feeding three different sets of
flexlink_flags from configure (the flags for `MKEXE`, `MKDLL` and
`MKSHAREDLIB`), but I think building those in OCaml is slightly
better than doing it in m4sh! The major reason possibly to leave it
as it is is that I do still intend to remove `OCAML_FLEXLINK`
completely (following on from 4.13's overhaul of the flexlink
bootstrap), so in principle all that stuff in `utils/config.mlp`
will be completely deleted.
Sounds cool!
Willyou please ping when you wnat me to review again?
|
Rebased, with 3 additional commits addressing the comments made previously. Also running through precheck#687 |
[[*,i[3456]86-*]], | ||
# Disable DT_TEXTREL warnings on Linux and BSD i386 | ||
# See https://github.com/ocaml/ocaml/issues/9800 | ||
[mksharedlib="$CC -shared \$(LDFLAGS) -Wl,-z,notext"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the order, relative to that originally given in #10835 which needs to be checked, but I don't think that it was ever correct for hard-coded flags to appear _after $(LDFLAGS)
David Allsopp (2022/05/10 08:06 -0700):
@dra27 commented on this pull request.
> [[*,i[3456]86-*]],
# Disable DT_TEXTREL warnings on Linux and BSD i386
# See #9800
- [mksharedlib="$CC -shared \$(LDFLAGS) -Wl,-z,notext"],
This changes the order, relative to that originally given in #10835
which needs to be checked, but I don't think that it was ever correct
for hard-coded flags to appear _after `$(LDFLAGS)`
I agree it was not!
|
Tidies up the flexlink aspects. Previously, it was viewed as MKEXE and a special case needed in flexlink bootstrap to build the runtime without using flexlink. This commit moves the flags decisions into configure where they belong and now exposes two versions of a command which links executables. MKEXE _may_ link using a C compiler but may be a direct call to a wrapper for a linker (i.e. flexlink). MKEXE_VIA_CC _always_ creates an executable by calling the C compiler. Rather than deriving the entire mkexe command line, configure now determines what the _command_ will be (i.e. `$(CC)` or `$(FLEXLINK_CMD)`) and the flags which get passed to that (and their `-link` prefixes, if necessary) are computed _at the end of the process_ which hopefully simplifies the number of special cases which have to be considered during configuration.
I wonder whether it wouldn't be worth definind If that was done, couldn't we then have configure expand the definition of Also, although I guess the situation has not been introduced by the present |
I think this might be hard to do simultaneously with this PR - your PR to generate
I think this could be, yes - I'll have a look in a bit! |
This is a long overdue overhaul of the way
$(MKEXE)
is constructed.$(MKEXE)
either builds an executable using the C compiler (Unix, and Cygwin in non-shared mode) or it's a call to a linker wrapper (flexlink). There's also the separate$(MKEXE_USING_COMPILER)
which is needed for the bytecode startup header and for building the non-shared runtime when bootstrapping flexlink.At present, there's a lot of subtlety embedded in both
configure.ac
andMakefile.config.in
(for example, the fact that the Microsoft linker requires linker flags after objects, not before, is encoded inMakefile.config.in
and not mentioned) and a few latent bugs (for example, the handling of$(LDFLAGS)
is missing on the flexlink paths). There's also a lot of "weirdness" about argument prefixing - for example, the Unicode startup instruction (-municode
) should be passed directly to gcc in$(MKEXE_USING_COMPILER)
but prefixed-link
when passed to flexlink. However, in the msvc ports, the equivalent/ENTRY:wmainCRTStartup
must be passed prefixed-link
to flexlink and also prefixed-link
//link
to cl. There is also the question of$(CFLAGS)
, which may be used when$(MKEXE)
is a C compiler, but cannot be passed to flexlink, which doesn't call the C compiler.Ultimately, I expect to remove this confusion by changing flexlink to cease being a wrapper around the linker and instead a compilation step to generate the required startup objects. However, this work is un-designed and un-scheduled, so we the mess could do with dealing with. The present code also severely complicates some other simplifications in the build system for the generation of
utils/config.ml
andocamltest/ocamltest_config.ml
.My solution here is to change the way
$mkexe
is constructed inconfigure.ac
.configure
now considers$mkexe_cmd
- the command to be executed (which might include parameters). The variables which are to be passed to it are considered at the end of the process, just beforeconfig.status
is generated (this is whatAC_CONFIG_COMMANDS_PRE
does). This allows all of the computations in the main body of configure to consider the flags only, and not how they will be passed - for example,$mkexedebugflag
is now-g
at all times (or cleared in MSVC, where it can't be used) and then only at the end do we worry about whether it needs to be prefixed-link
.I've renamed
MKEXE_USING_COMPILER
to be more explicit about how it really works - it is nowMKEXE_VIA_CC
. I've attempted with comments before theAC_CONFIG_COMMANDS_PRE
call to explain the variables which are constructed. A nice side-effect of this, if we also move the testsuite/manual commands (as suggested in #10411 (comment)) is thatMakefile.config
no longer containsif
statements - it's actually a configuration file.Along the way,
$(OC_LDFLAGS)
and$(LDFLAGS)
are now correct handled by flexlink.This has been through precheck, but it should obviously go through again once reviewed.