Skip to content

Conversation

@dra27
Copy link
Owner

@dra27 dra27 commented Aug 27, 2025

No description provided.

@dra27 dra27 added relocatable PRs related to the Relocatable Compiler project CI: Full matrix Full CI test matrix labels Aug 27, 2025
@dra27 dra27 changed the title [Relocatable] Follow-up 9: Document and clarify handling of set-but-empty environment variables [Relocatable] Follow-up 8: Document and clarify handling of set-but-empty environment variables Aug 28, 2025
@dra27 dra27 force-pushed the relocatable-testing branch from 3c8b5c1 to 2a7e0ad Compare September 9, 2025 22:19
@dra27 dra27 force-pushed the environmental-emptiness branch from fdb5b50 to 6a5d951 Compare September 9, 2025 22:21
@dra27 dra27 changed the base branch from relocatable-testing to trunk September 13, 2025 13:36
@dra27 dra27 force-pushed the environmental-emptiness branch from 6a5d951 to be2d71c Compare September 13, 2025 15:39
@dra27 dra27 force-pushed the environmental-emptiness branch from be2d71c to a3b346a Compare November 9, 2025 08:27
@dra27 dra27 force-pushed the environmental-emptiness branch from a3b346a to b9275d3 Compare November 28, 2025 21:48
@dra27 dra27 changed the base branch from trunk to relocatable-testing November 30, 2025 14:34
@dra27 dra27 force-pushed the relocatable-testing branch from d644c59 to 63922b2 Compare November 30, 2025 14:36
@dra27 dra27 force-pushed the environmental-emptiness branch from b9275d3 to 9fe73e4 Compare November 30, 2025 14:36
@dra27 dra27 force-pushed the relocatable-testing branch from 63922b2 to 198fcfd Compare December 10, 2025 11:10
@dra27 dra27 force-pushed the environmental-emptiness branch from 9fe73e4 to b70a613 Compare December 10, 2025 12:53
@dra27 dra27 force-pushed the relocatable-testing branch from 198fcfd to 56b115d Compare December 11, 2025 18:34
@dra27 dra27 force-pushed the environmental-emptiness branch from b70a613 to bd253ee Compare December 11, 2025 18:34
@dra27 dra27 force-pushed the relocatable-testing branch from 56b115d to 5c4d9f3 Compare December 12, 2025 11:17
Clarify in various places the behaviour of reading an environment
variable which is "Set But Null" (i.e. equal to the empty string as
opposed to unset)
For Unix, the Filename module now treats TMPDIR being set to the
empty string, as if it were not set at all (which causes it to use /tmp
instead).
If TMPDIR is set to the empty string, the Unix build of ocamlyacc now
defaults to /tmp (as it would if TMPDIR were not set at all).

The Windows default for when TMPDIR is not set is alredy the current
directory, so no change is required.
By making tmpdir explicitly "." in the rare corner-case of TMPDIR being
set to the empty string on Windows, it becomes unnecessary to keep
checking whether tmpdir is zero-length.
Use the non-raising Sys.getenv_opt internally in the Windows
implementation of the Unix module. In passing, treat the highly unlikely
corner case of COMSPEC being "Set But Null" as if COMSPEC were not set.
Previously, invocations such as

OCAML_COLOR= ocamlopt

emitted warning 46 (bad-env-variable) which is not particularly helpful.
At present, Compmisc.set_from_env is used to implement OCAML_COLOR and
OCAML_ERROR_STYLE, neither of which attached significance to the empty
string. Compmisc.set_from_env is there changed to explictly ignore the
environment variable value if it is "".
Most uses in ocamltest were via its safe_getenv function which already
made unset and empty equivalent. This generalises the underlying
getenv_with_default_value function always to return the default value if
the variable is _either_ unset or set to the empty string.
The handling of OCAML_RUNTIME_EVENTS_DIR was incorrect if the value as
"Set But Null" and the intention in the manual for
OCAML_RUNTIME_EVENTS_START and OCAML_RUNTIME_EVENTS_PRESERVE is clearly
that they should be set to non-empty values in order to trigger the
required effect.

All three variables are now ignored if they are set, but to an empty
string.
@dra27 dra27 force-pushed the environmental-emptiness branch from bd253ee to 193aabe Compare December 17, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: Full matrix Full CI test matrix relocatable PRs related to the Relocatable Compiler project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants