Skip to content

Commit 493ac93

Browse files
magicusJornVernee
andcommitted
8244533: Configure should abort on missing short names in Windows
Co-authored-by: Jorn Vernee <[email protected]> Co-authored-by: Magnus Ihse Bursie <[email protected]> Reviewed-by: erikj
1 parent 8c1b915 commit 493ac93

File tree

6 files changed

+119
-48
lines changed

6 files changed

+119
-48
lines changed

doc/building.html

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,29 @@ <h3 id="special-considerations">Special Considerations</h3>
282282
having slow disk access will significantly increase build times. If you
283283
need to use a network share for the source code, see below for
284284
suggestions on how to keep the build artifacts on a local disk.</p></li>
285-
<li><p>On Windows, if using <a href="#cygwin">Cygwin</a>, extra care
286-
must be taken to make sure the environment is consistent. It is
287-
recommended that you follow this procedure:</p>
285+
<li><p>On Windows, extra care must be taken to have a smooth building
286+
experience:</p>
287+
<ul>
288+
<li><p>Make sure that all relevant paths have short names. Short names
289+
are used by the build system to create space-free alternative paths.
290+
Short name creation is enabled per volume. The default setting can be
291+
checked with the command: <code>fsutil 8dot3name query</code>. If short
292+
name creation was turned off when a directory was created, it will not
293+
have a short name. Whether a short name exists can be checked by running
294+
<code>dir /X</code> in the containing directory (in cmd.exe). If a short
295+
path is present you should see something like 'ASDF~1' being displayed
296+
in one of the columns of the ouput. If a directory is missing a short
297+
name, the safest way to get one is to enable short names for that
298+
particular volume with
299+
<code>fsutil 8dot3name set &lt;drive letter&gt;: 0</code> (note that
300+
you need to run as administrator for this), and then re-create the
301+
particular directory. A short name should be generated automatically
302+
then. Another option is to manually assign a short name to the directory
303+
using
304+
<code>fsutil file setShortName &lt;path&gt; &lt;short name&gt;</code>.</p></li>
305+
<li><p>If using <a href="#cygwin">Cygwin</a>, you must make sure the
306+
file permissions and attributes between Windows and Cygwin are
307+
consistent. It is recommended that you follow this procedure:</p>
288308
<ul>
289309
<li><p>Create the directory that is going to contain the top directory
290310
of the JDK clone by using the <code>mkdir</code> command in the Cygwin
@@ -294,6 +314,9 @@ <h3 id="special-considerations">Special Considerations</h3>
294314
<li><p>Do not put the JDK clone in a path under your Cygwin home
295315
directory. This is especially important if your user name contains
296316
spaces and/or mixed upper and lower case letters.</p></li>
317+
</ul>
318+
<p>Failure to follow these procedures might result in hard-to-debug
319+
build problems.</p></li>
297320
<li><p>You need to install a git client. You have two choices, Cygwin
298321
git or Git for Windows. Unfortunately there are pros and cons with each
299322
choice.</p>
@@ -311,9 +334,7 @@ <h3 id="special-considerations">Special Considerations</h3>
311334
line ending problems, make sure you set <code>core.autocrlf</code> to
312335
<code>false</code> (this is asked during installation).</p></li>
313336
</ul></li>
314-
</ul>
315-
<p>Failure to follow this procedure might result in hard-to-debug build
316-
problems.</p></li>
337+
</ul></li>
317338
</ul>
318339
<h2 id="build-hardware-requirements">Build Hardware Requirements</h2>
319340
<p>The JDK is a massive project, and require machines ranging from

doc/building.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,39 @@ on where and how to check out the source code.
8383
for the source code, see below for suggestions on how to keep the build
8484
artifacts on a local disk.
8585

86-
* On Windows, if using [Cygwin](#cygwin), extra care must be taken to make sure
87-
the environment is consistent. It is recommended that you follow this
88-
procedure:
89-
90-
* Create the directory that is going to contain the top directory of the JDK
91-
clone by using the `mkdir` command in the Cygwin bash shell. That is, do
92-
*not* create it using Windows Explorer. This will ensure that it will have
93-
proper Cygwin attributes, and that it's children will inherit those
94-
attributes.
95-
96-
* Do not put the JDK clone in a path under your Cygwin home directory. This
97-
is especially important if your user name contains spaces and/or mixed
98-
upper and lower case letters.
86+
* On Windows, extra care must be taken to have a smooth building experience:
87+
88+
* Make sure that all relevant paths have short names. Short names are used by
89+
the build system to create space-free alternative paths. Short name
90+
creation is enabled per volume. The default setting can be checked with the
91+
command: `fsutil 8dot3name query`. If short name creation was turned off
92+
when a directory was created, it will not have a short name. Whether a
93+
short name exists can be checked by running `dir /X` in the containing
94+
directory (in cmd.exe). If a short path is present you should see something
95+
like 'ASDF~1' being displayed in one of the columns of the ouput. If a
96+
directory is missing a short name, the safest way to get one is to enable
97+
short names for that particular volume with `fsutil 8dot3name set <drive
98+
letter>: 0` (note that you need to run as administrator for this), and then
99+
re-create the particular directory. A short name should be generated
100+
automatically then. Another option is to manually assign a short name to
101+
the directory using `fsutil file setShortName <path> <short name>`.
102+
103+
* If using [Cygwin](#cygwin), you must make sure the file permissions and
104+
attributes between Windows and Cygwin are consistent. It is recommended
105+
that you follow this procedure:
106+
107+
* Create the directory that is going to contain the top directory of the
108+
JDK clone by using the `mkdir` command in the Cygwin bash shell. That is,
109+
do *not* create it using Windows Explorer. This will ensure that it will
110+
have proper Cygwin attributes, and that it's children will inherit those
111+
attributes.
112+
113+
* Do not put the JDK clone in a path under your Cygwin home directory. This
114+
is especially important if your user name contains spaces and/or mixed
115+
upper and lower case letters.
116+
117+
Failure to follow these procedures might result in hard-to-debug build
118+
problems.
99119

100120
* You need to install a git client. You have two choices, Cygwin git or Git
101121
for Windows. Unfortunately there are pros and cons with each choice.
@@ -113,9 +133,6 @@ on where and how to check out the source code.
113133
make sure you set `core.autocrlf` to `false` (this is asked during
114134
installation).
115135

116-
Failure to follow this procedure might result in hard-to-debug build
117-
problems.
118-
119136
## Build Hardware Requirements
120137

121138
The JDK is a massive project, and require machines ranging from decent to

doc/hotspot-unit-tests.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ <h3 id="nearness">Nearness</h3>
189189
<p>Prefer having checks inside test code.</p>
190190
<p>Not only does having test logic outside, e.g. verification method,
191191
depending on asserts in product code contradict with several items above
192-
but also decreases tests readability and stability. It is much easier
192+
but also decreases test's readability and stability. It is much easier
193193
to understand that a test is testing when all testing logic is located
194194
inside a test or nearby in shared test libraries. As a rule of thumb,
195195
the closer a check to a test, the better.</p>
@@ -198,7 +198,7 @@ <h3 id="several-checks">Several checks</h3>
198198
<p>Prefer <code>EXPECT</code> over <code>ASSERT</code> if possible.</p>
199199
<p>This is related to the <a href="#informativeness">informativeness</a>
200200
property of tests, information for other checks can help to better
201-
localize a defects root-cause. One should use <code>ASSERT</code> if it
201+
localize a defect's root-cause. One should use <code>ASSERT</code> if it
202202
is impossible to continue test execution or if it does not make much
203203
sense. Later in the text, <code>EXPECT</code> forms will be used to
204204
refer to both <code>ASSERT/EXPECT</code>.</p>
@@ -235,7 +235,7 @@ <h3 id="floating-point-comparison">Floating-point comparison</h3>
235235
<code>eps</code>.</p>
236236
<h3 id="c-string-comparison">C string comparison</h3>
237237
<p>Use string special macros for C strings comparisons.</p>
238-
<p><code>EXPECT_EQ</code> just compares pointers values, which is
238+
<p><code>EXPECT_EQ</code> just compares pointers' values, which is
239239
hardly what one wants comparing C strings. GoogleTest provides
240240
<code>EXPECT_STREQ</code> and <code>EXPECT_STRNE</code> macros to
241241
compare C string contents. There are also case-insensitive versions
@@ -293,7 +293,7 @@ <h3 id="test-group-names">Test group names</h3>
293293
<p>This naming scheme helps to find tests, filter them and simplifies
294294
test failure analysis. For example, class <code>Foo</code> - test group
295295
<code>Foo</code>, compiler logging subsystem - test group
296-
<code>CompilerLogging</code>, G1 GC test group <code>G1GC</code>, and
296+
<code>CompilerLogging</code>, G1 GC - test group <code>G1GC</code>, and
297297
so forth.</p>
298298
<h3 id="filename">Filename</h3>
299299
<p>A test file must have <code>test_</code> prefix and <code>.cpp</code>
@@ -345,7 +345,7 @@ <h3 id="fixture-classes">Fixture classes</h3>
345345
<h3 id="friend-classes">Friend classes</h3>
346346
<p>All test purpose friends should have either <code>Test</code> or
347347
<code>Testable</code> suffix.</p>
348-
<p>It greatly simplifies understanding of friendships purpose and
348+
<p>It greatly simplifies understanding of friendship's purpose and
349349
allows statically check that private members are not exposed
350350
unexpectedly. Having <code>FooTest</code> as a friend of
351351
<code>Foo</code> without any comments will be understood as a necessary
@@ -435,7 +435,7 @@ <h3 id="test-specific-flags">Test-specific flags</h3>
435435
<h3 id="flag-restoring">Flag restoring</h3>
436436
<p>Restore changed flags.</p>
437437
<p>It is quite common for tests to configure JVM in a certain way
438-
changing flags values. GoogleTest provides two ways to set up
438+
changing flags' values. GoogleTest provides two ways to set up
439439
environment before a test and restore it afterward: using either
440440
constructor and destructor or <code>SetUp</code> and
441441
<code>TearDown</code> functions. Both ways require to use a test fixture
@@ -444,7 +444,7 @@ <h3 id="flag-restoring">Flag restoring</h3>
444444
be used in such cases to restore/set values.</p>
445445
<p>Caveats:</p>
446446
<ul>
447-
<li><p>Changing a flags value could break the invariants between flags'
447+
<li><p>Changing a flag's value could break the invariants between flags'
448448
values and hence could lead to unexpected/unsupported JVM
449449
state.</p></li>
450450
<li><p><code>FLAG_SET_*</code> macros can change more than one flag (in

make/autoconf/basic_windows.m4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -159,7 +159,7 @@ AC_DEFUN([BASIC_SETUP_PATHS_WINDOWS],
159159
else
160160
WINENV_PREFIX_ARG="$WINENV_PREFIX"
161161
fi
162-
FIXPATH_ARGS="-e $PATHTOOL -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR -c $CMD -q"
162+
FIXPATH_ARGS="-e $PATHTOOL -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR -c $CMD"
163163
FIXPATH_BASE="$BASH $FIXPATH_DIR/fixpath.sh $FIXPATH_ARGS"
164164
FIXPATH="$FIXPATH_BASE exec"
165165
@@ -215,7 +215,7 @@ AC_DEFUN([BASIC_WINDOWS_FINALIZE_FIXPATH],
215215
if test "x$OPENJDK_BUILD_OS" = xwindows; then
216216
FIXPATH_CMDLINE=". $TOPDIR/make/scripts/fixpath.sh -e $PATHTOOL \
217217
-p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR \
218-
-c $CMD -q"
218+
-c $CMD"
219219
$ECHO > $OUTPUTDIR/fixpath '#!/bin/bash'
220220
$ECHO >> $OUTPUTDIR/fixpath export PATH='"[$]PATH:'$PATH'"'
221221
$ECHO >> $OUTPUTDIR/fixpath $FIXPATH_CMDLINE '"[$]@"'

make/autoconf/util_paths.m4

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,32 @@ AC_DEFUN([UTIL_PREPEND_TO_PATH],
5858
# 2) The path will be absolute, and it will be in unix-style (on
5959
# cygwin).
6060
# $1: The name of the variable to fix
61-
# $2: if NOFAIL, errors will be silently ignored
61+
# $2: if NOFAIL, if the path cannot be resolved then errors will not be
62+
# reported and an empty path will be set
6263
AC_DEFUN([UTIL_FIXUP_PATH],
6364
[
6465
# Only process if variable expands to non-empty
6566
path="[$]$1"
6667
if test "x$path" != x; then
6768
if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
68-
if test "x$2" = "xNOFAIL"; then
69-
quiet_option="-q"
69+
imported_path=`$FIXPATH_BASE -q import "$path"`
70+
if test $? -ne 0 || test ! -e $imported_path; then
71+
if test "x$2" != "xNOFAIL"; then
72+
AC_MSG_NOTICE([The path of $1, which is given as "$path", can not be properly resolved.])
73+
AC_MSG_NOTICE([Please see the section "Special Considerations" in building.md.])
74+
AC_MSG_NOTICE([This is the error message given by fixpath:])
75+
# Rerun fixpath without -q to get an error message
76+
$FIXPATH_BASE import "$path"
77+
AC_MSG_ERROR([Cannot continue])
78+
else
79+
imported_path=""
80+
fi
7081
fi
71-
imported_path=`$FIXPATH_BASE $quiet_option import "$path"`
72-
$FIXPATH_BASE verify "$imported_path"
82+
83+
$FIXPATH_BASE -q verify "$imported_path"
7384
if test $? -ne 0; then
7485
if test "x$2" != "xNOFAIL"; then
75-
AC_MSG_ERROR([The path of $1, which resolves as "$path", could not be imported.])
86+
AC_MSG_ERROR([The path of $1, which resolves as "$path", could not be verified.])
7687
else
7788
imported_path=""
7889
fi
@@ -83,7 +94,7 @@ AC_DEFUN([UTIL_FIXUP_PATH],
8394
if test "x$imported_path_lower" != "x$orig_path_lower"; then
8495
$1="$imported_path"
8596
fi
86-
else
97+
else # non-Windows
8798
[ if [[ "$path" =~ " " ]]; then ]
8899
if test "x$2" != "xNOFAIL"; then
89100
AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
@@ -232,15 +243,19 @@ AC_DEFUN([UTIL_FIXUP_EXECUTABLE],
232243
# This is a path with slashes, don't look at $PATH
233244
if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
234245
# fixpath.sh import will do all heavy lifting for us
235-
new_path=`$FIXPATH_BASE import "$path"`
246+
new_path=`$FIXPATH_BASE -q import "$path"`
236247
237-
if test ! -e $new_path; then
248+
if test $? -ne 0 || test ! -e $new_path; then
238249
# It failed, but maybe spaces were part of the path and not separating
239250
# the command and argument. Retry using that assumption.
240-
new_path=`$FIXPATH_BASE import "$input"`
241-
if test ! -e $new_path; then
242-
AC_MSG_NOTICE([The command for $1, which resolves as "$input", can not be found.])
243-
AC_MSG_ERROR([Cannot locate $input])
251+
new_path=`$FIXPATH_BASE -q import "$input"`
252+
if test $? -ne 0 || test ! -e $new_path; then
253+
AC_MSG_NOTICE([The command for $1, which is given as "$input", can not be properly resolved.])
254+
AC_MSG_NOTICE([Please see the section "Special Considerations" in building.md.])
255+
AC_MSG_NOTICE([This is the error message given by fixpath:])
256+
# Rerun fixpath without -q to get an error message
257+
$FIXPATH_BASE import "$input"
258+
AC_MSG_ERROR([Cannot continue])
244259
fi
245260
# It worked, clear all "arguments"
246261
arguments=""
@@ -348,7 +363,15 @@ AC_DEFUN([UTIL_SETUP_TOOL],
348363
else
349364
# Otherwise we believe it is a complete path. Use it as it is.
350365
if test ! -x "$tool_command" && test ! -x "${tool_command}.exe"; then
351-
AC_MSG_ERROR([User supplied tool $1="$tool_command" does not exist or is not executable])
366+
# Maybe the path had spaces in it; try again with the entire argument
367+
if test ! -x "$tool_override" && test ! -x "${tool_override}.exe"; then
368+
AC_MSG_ERROR([User supplied tool $1="$tool_override" does not exist or is not executable])
369+
else
370+
# We successfully located the executable assuming the spaces were part of the path.
371+
# We can't combine using paths with spaces and arguments, so assume tool_args is empty.
372+
tool_command="$tool_override"
373+
tool_args=""
374+
fi
352375
fi
353376
if test ! -x "$tool_command"; then
354377
tool_command="${tool_command}.exe"

make/scripts/fixpath.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
44
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
#
66
# This code is free software; you can redistribute it and/or modify it
@@ -157,11 +157,21 @@ function import_path() {
157157
if [[ $? -eq 0 && -e "$unixpath" ]]; then
158158
if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then
159159
# If it is not in envroot, it's a generic windows path
160-
if [[ ! $winpath =~ ^[-_.:\\a-zA-Z0-9]*$ ]] ; then
160+
if [[ ! $winpath =~ ^[-_.:~\\a-zA-Z0-9]*$ ]] ; then
161161
# Path has forbidden characters, rewrite as short name
162162
# This monster of a command uses the %~s support from cmd.exe to
163163
# reliably convert to short paths on all winenvs.
164164
shortpath="$($CMD /q /c for %I in \( "$winpath" \) do echo %~sI 2>/dev/null | tr -d \\n\\r)"
165+
if [[ ! $shortpath =~ ^[-_.:~\\a-zA-Z0-9]*$ ]] ; then
166+
if [[ $QUIET != true ]]; then
167+
echo fixpath: failure: Path "'"$path"'" could not be converted to short path >&2
168+
fi
169+
if [[ $IGNOREFAILURES != true ]]; then
170+
exit 1
171+
else
172+
shortpath=""
173+
fi
174+
fi
165175
unixpath="$($PATHTOOL -u "$shortpath")"
166176
# unixpath is based on short name
167177
fi

0 commit comments

Comments
 (0)