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

More configure fixes #13164

Merged
merged 15 commits into from
May 17, 2024
Merged

More configure fixes #13164

merged 15 commits into from
May 17, 2024

Conversation

MisterDA
Copy link
Contributor

This PR attempts to remove accumulated Autoconf cruft, outdated code/comments, and fix bugs.

Unfortunately the commit configure: set the value of AC_DEFINE macros to 1 adds some noise to this PR.

No change entry needed.
cc @shindere

Copy link
Contributor

@dustanddreams dustanddreams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I am moderately worried about the macOS specific changes, though - regarding the detection of getentropy, maybe older versions actually needed <sys/random.h> at some point, have you been able to check this?

@MisterDA
Copy link
Contributor Author

I am moderately worried about the macOS specific changes, though - regarding the detection of getentropy, maybe older versions actually needed <sys/random.h> at some point, have you been able to check this?

The manual states it was introduced in Mac OS X 10.12 (2016). I have no proof, but it's likely that it was never made available in another header.
If you're concerned about removing the header inclusion in the autoconf test, note that it doesn't change anything: the compiler may warn that it cannot find a previous declaration, but will still link the test program, and autoconf will discover getentropy(2).
Am I understanding your concern correctly? Does this answer it?

@dustanddreams
Copy link
Contributor

The manual states it was introduced in Mac OS X 10.12 (2016). I have no proof, but it's likely that it was never made available in another header. If you're concerned about removing the header inclusion in the autoconf test, note that it doesn't change anything: the compiler may warn that it cannot find a previous declaration, but will still link the test program, and autoconf will discover getentropy(2). Am I understanding your concern correctly? Does this answer it?

I had misread the changes to runtime/sys.c and wrongly had the impression that the inclusion of <sys/random.h> had been removed. For the autoconf tests it does indeed not matter to explicitly include headers when only a linking test is performed.

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like every aspect of this PR, thank you 🙂 Adding a green tick, but I'll let @shindere have a chance to comment before merging.

@shindere
Copy link
Contributor

shindere commented May 15, 2024 via email

@shindere
Copy link
Contributor

shindere commented May 15, 2024 via email

@MisterDA
Copy link
Contributor Author

  1. Wouldn't it be better to split it and to squash each of its parts in the commit that removes the corresponding macros?

Will do.

  1. […] Also, after all, why not introducing the file right now and so it would be its inclusion which could be protected by #ifndef CAML_INTERNAL.

Great idea, I'll re-introduce compatibility.h.

And, out of curiosity, re:"add missing quotes in branch", you mention that using autoconf-2.70 gives an error but I thought we were using it already so how is it possible that this got unnoticed?

Without the [ … ] quotes, the code is brittle and sensitive to the context. When I removed other occurrences of AC_CHECK_DECL which occurred before this bug, Autoconf stopped expanding the macro before the bug, but expanded it at its sole occurrence inside the expansion of the AS_IF macro, which led to a wrong quoting, wrong nesting of if blocks and parentheses.

@shindere
Copy link
Contributor

shindere commented May 16, 2024 via email

@MisterDA MisterDA force-pushed the configure-fixes branch 2 times, most recently from 1bfba09 to 123a2f2 Compare May 16, 2024 06:32
@MisterDA
Copy link
Contributor Author

Rebased. I went with conf_compat.h.

runtime/caml/config_compat.h Outdated Show resolved Hide resolved
@MisterDA MisterDA force-pushed the configure-fixes branch 2 times, most recently from 2bbc52b to bb0b6f7 Compare May 17, 2024 12:14
@MisterDA
Copy link
Contributor Author

Rebased for the MSVC CI fix.

@shindere
Copy link
Contributor

shindere commented May 17, 2024 via email

@shindere
Copy link
Contributor

shindere commented May 17, 2024 via email

@MisterDA
Copy link
Contributor Author

Sorry, I'm getting confused: didn't we agree that "Keep former Autoconf-defined macros for compatibility" would be split and melt into the previous commits?

I split the commit in two: we already had a definition of HAS_STDINT_H that I wanted to deprecate, so this went into the first commit, and served as introduction for the compatibility header. The code redefining HAS_NANOSECOND_STAT was merged in the other commit. I think this is rather clean.

If I may nitpick about the name of the compatibility header: do we really care that the macros come from config? Can't there be macros from other places that we may want to deprecate and whose definition would move to a compatibility header during the deprecation period?

We have the example of the compatibility.h header from the 4.x branch for functions that were not namespaced. I was only concerned about macros related to configure, and I can't predict the future, which is why I went for a name indicating "config". It should be relatively harmless to use this header for whatever, so yes, I can go with compatibility.h and see what happens.

Fixes error with stricter quoting requirements of autoconf-2.70.
Support for getentropy on macOS was already correctly detected in the
C code, but it's nicer to detect it in the configure script, otherwise
Autoconf prints a message telling it couldn't detect getentropy.

The includes are not needed to check if getentropy is present.
mach_timebase_info and mach_absolute time were used from
b7f0494
to
cd01cac
where they were replaced by clock_gettime_nsec_np.
It can be moved to the preprocessor completely.
The following variables stopped to occur in other files than
configure.ac, thus ceased to need to be substituted in other files.

flexlink_flags, mkexe_extra_flags, mkdll_ldflags_exp, mkexe_ldflags_exp:
319b77f

target_bindir: 8681e66

The following never occurred in other files so don't need to be
substituted.
has_monotonic_clock: b7f0494

The following is probably a left-over or a duplicate of
EXEC_MAGIC_LENGTH and has never been used.
MAGIC_NUMBER_LENGTH: 7892e6f
@shindere
Copy link
Contributor

shindere commented May 17, 2024 via email

@MisterDA
Copy link
Contributor Author

please lets rename the header to the more general! :)

Done.

Inline otherlibs/unix/nanosecond_stat.h into
otherlibs/unix/stat_unix.c since the latter is the only user. Use the
Autoconf-generated macros for each member name rather than an ad-hoc
macro.

Keep the former macro HAS_NANOSECOND_STAT for compatibility.
No need to get the headers right, the program will link anyway.
The Autoconf manual suggests not to rely on the default value (1).
The diff was generated with:

    sed -i -E 's/AC_DEFINE\(\[([_A-Z0-9]*)\]\)/AC_DEFINE([\1], [1])/g' \
      configure.ac aclocal.m4
@shindere shindere merged commit 51e4d9a into ocaml:trunk May 17, 2024
15 checks passed
@MisterDA MisterDA deleted the configure-fixes branch May 17, 2024 15:35
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.

None yet

4 participants