Refactoring: Introduce distinct host and target rpath var setters.
Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.
`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building). Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"
What this commit does:
* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
to `maketest.py`
* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
Instead, it passes along the HOST and TARGET rpath setup vars in
environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`
* Also, pass the current stage number to maketest.py; it in turn
passes it (via an env var) to run-make tests.
This allows the run-make tests to selectively change behavior
(e.g. turn themselves off) to deal with incompatibilities with
e.g. stage1.
* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
and the file to generate to drive that command (`RUN_BINFILE`). The
main thing this enables is that `RUN` can now setup the
`TARGET_RPATH_ENV` without having to dirty up the runner code in
each of the `run-make` Makefiles.
* Cleanup: Factored out commands to delete dylib/rlib into
REMOVE_DYLIBS/REMOVE_RLIBS.
There were places where we were only calling `rm $(call DYLIB,foo)`
even though we really needed to get rid of the whole glob (at least
based on alex's findings on #13753 that removing the symlink does not
suffice).
Therefore rather than peppering the code with the awkward
`rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
`REMOVE_DYLIBS` user function that expands into that when called.
After I adding an analogous `REMOVE_RLIBS`, I changed all of the
existing calls that rm dylibs or rlibs to use these routines
instead.
Note that the latter is not a true refactoring since I may have
changed cases where it was our intent to only remove the sym-link.
(But if that is the case, then we need to more deeply investigate
alex's findings on #13753 where the system was still dynamically
loading up the non-symlinked libraries that it finds on the load
path.)
* Added RPATH_LINK_SEARCH command and use it on Linux.
On some platforms, namely Linux, when you have libboot.so that has
its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
linker still complains when you do the link step and it does not
know where to find libraries that libboot.so depends upon that live
in HOSTDIR (think e.g. librustuv.so).
As far as I can tell, the GNU linker will consult the
LD_LIBRARY_PATH as part of the linking process to find such
libraries. But if you want to be more careful and not override
LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
way to tell the linker where it can find the libraries that
libboot.so needs. The solution to this on Linux is the
`-Wl,-rpath-link` command line option.
However, this command line option does not exist on Mac OS X, (which
appears to be figuring out how to resolve the libboot.dylib
dependency by some other means, perhaps by consulting the rpath
setting within libboot.dylib).
So, in order to abstract over this distinction, I added the
RPATH_LINK_SEARCH macro to the run-make infrastructure and added
calls to it where necessary to get Linux working. On architectures
other than Linux, the macro expands to nothing.
* Disable miscellaneous tests atop stage1.
* An especially interesting instance of the previous bullet point:
Excuse regex from doing rustdoc tests atop stage1.
This was a (nearly-) final step to get `make check-stage1` working
again.
The use of a special-case check for regex here is ugly but is
analogous other similar checks for regex such as the one that landed
in PR #13844.
The way this is written, the user will get a reminder that
doc-crate-regex is being skipped whenever their rules attempt to do
the crate documentation tests. This is deliberate: I want people
running `make check-stage1` to be reminded about which cases are
being skipped. (But if such echo noise is considered offensive, it
can obviously be removed.)
* Got windows working with the above changes.
This portion of the commit is a cleanup revision of the (previously
mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
setup and extension is handled in order to accommodate Windows' (1.)
use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
entries (problematic for make and for interoperation with tools at
the shell).
* In addition, since the code has been rearchitected to pass the
HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
environment-variable setting command, there is no need to for the
convert_path_spec calls in maketest.py, which in fact were put in
place to placate Windows but were now causing the Windows builds to
fail. Instead we just convert the paths to absolute paths just like
all of the other path arguments.
Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).
2014-04-25 11:22:23 -05:00
|
|
|
# These deliberately use `=` and not `:=` so that client makefiles can
|
|
|
|
# augment HOST_RPATH_DIR / TARGET_RPATH_DIR.
|
|
|
|
HOST_RPATH_ENV = \
|
2014-06-23 06:12:37 -05:00
|
|
|
$(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
|
Refactoring: Introduce distinct host and target rpath var setters.
Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.
`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building). Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"
What this commit does:
* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
to `maketest.py`
* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
Instead, it passes along the HOST and TARGET rpath setup vars in
environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`
* Also, pass the current stage number to maketest.py; it in turn
passes it (via an env var) to run-make tests.
This allows the run-make tests to selectively change behavior
(e.g. turn themselves off) to deal with incompatibilities with
e.g. stage1.
* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
and the file to generate to drive that command (`RUN_BINFILE`). The
main thing this enables is that `RUN` can now setup the
`TARGET_RPATH_ENV` without having to dirty up the runner code in
each of the `run-make` Makefiles.
* Cleanup: Factored out commands to delete dylib/rlib into
REMOVE_DYLIBS/REMOVE_RLIBS.
There were places where we were only calling `rm $(call DYLIB,foo)`
even though we really needed to get rid of the whole glob (at least
based on alex's findings on #13753 that removing the symlink does not
suffice).
Therefore rather than peppering the code with the awkward
`rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
`REMOVE_DYLIBS` user function that expands into that when called.
After I adding an analogous `REMOVE_RLIBS`, I changed all of the
existing calls that rm dylibs or rlibs to use these routines
instead.
Note that the latter is not a true refactoring since I may have
changed cases where it was our intent to only remove the sym-link.
(But if that is the case, then we need to more deeply investigate
alex's findings on #13753 where the system was still dynamically
loading up the non-symlinked libraries that it finds on the load
path.)
* Added RPATH_LINK_SEARCH command and use it on Linux.
On some platforms, namely Linux, when you have libboot.so that has
its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
linker still complains when you do the link step and it does not
know where to find libraries that libboot.so depends upon that live
in HOSTDIR (think e.g. librustuv.so).
As far as I can tell, the GNU linker will consult the
LD_LIBRARY_PATH as part of the linking process to find such
libraries. But if you want to be more careful and not override
LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
way to tell the linker where it can find the libraries that
libboot.so needs. The solution to this on Linux is the
`-Wl,-rpath-link` command line option.
However, this command line option does not exist on Mac OS X, (which
appears to be figuring out how to resolve the libboot.dylib
dependency by some other means, perhaps by consulting the rpath
setting within libboot.dylib).
So, in order to abstract over this distinction, I added the
RPATH_LINK_SEARCH macro to the run-make infrastructure and added
calls to it where necessary to get Linux working. On architectures
other than Linux, the macro expands to nothing.
* Disable miscellaneous tests atop stage1.
* An especially interesting instance of the previous bullet point:
Excuse regex from doing rustdoc tests atop stage1.
This was a (nearly-) final step to get `make check-stage1` working
again.
The use of a special-case check for regex here is ugly but is
analogous other similar checks for regex such as the one that landed
in PR #13844.
The way this is written, the user will get a reminder that
doc-crate-regex is being skipped whenever their rules attempt to do
the crate documentation tests. This is deliberate: I want people
running `make check-stage1` to be reminded about which cases are
being skipped. (But if such echo noise is considered offensive, it
can obviously be removed.)
* Got windows working with the above changes.
This portion of the commit is a cleanup revision of the (previously
mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
setup and extension is handled in order to accommodate Windows' (1.)
use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
entries (problematic for make and for interoperation with tools at
the shell).
* In addition, since the code has been rearchitected to pass the
HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
environment-variable setting command, there is no need to for the
convert_path_spec calls in maketest.py, which in fact were put in
place to placate Windows but were now causing the Windows builds to
fail. Instead we just convert the paths to absolute paths just like
all of the other path arguments.
Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).
2014-04-25 11:22:23 -05:00
|
|
|
TARGET_RPATH_ENV = \
|
2014-06-23 06:12:37 -05:00
|
|
|
$(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
|
2014-06-11 16:52:38 -05:00
|
|
|
|
2017-08-25 22:16:51 -05:00
|
|
|
RUSTC_ORIGINAL := $(RUSTC)
|
2016-04-14 17:51:03 -05:00
|
|
|
BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)'
|
2017-10-10 15:06:22 -05:00
|
|
|
BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)'
|
2015-08-21 23:43:56 -05:00
|
|
|
RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS)
|
2018-03-18 12:08:17 -05:00
|
|
|
RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR)
|
2017-10-10 15:06:22 -05:00
|
|
|
ifdef RUSTC_LINKER
|
2020-09-04 12:54:07 -05:00
|
|
|
RUSTC := $(RUSTC) -Clinker='$(RUSTC_LINKER)'
|
|
|
|
RUSTDOC := $(RUSTDOC) -Clinker='$(RUSTC_LINKER)'
|
2017-10-10 15:06:22 -05:00
|
|
|
endif
|
2015-08-26 18:57:56 -05:00
|
|
|
#CC := $(CC) -L $(TMPDIR)
|
2019-11-18 11:53:45 -06:00
|
|
|
HTMLDOCCK := '$(PYTHON)' '$(S)/src/etc/htmldocck.py'
|
2017-11-23 09:19:50 -06:00
|
|
|
CGREP := "$(S)/src/etc/cat-and-grep.sh"
|
Refactoring: Introduce distinct host and target rpath var setters.
Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.
`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building). Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"
What this commit does:
* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
to `maketest.py`
* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
Instead, it passes along the HOST and TARGET rpath setup vars in
environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`
* Also, pass the current stage number to maketest.py; it in turn
passes it (via an env var) to run-make tests.
This allows the run-make tests to selectively change behavior
(e.g. turn themselves off) to deal with incompatibilities with
e.g. stage1.
* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
and the file to generate to drive that command (`RUN_BINFILE`). The
main thing this enables is that `RUN` can now setup the
`TARGET_RPATH_ENV` without having to dirty up the runner code in
each of the `run-make` Makefiles.
* Cleanup: Factored out commands to delete dylib/rlib into
REMOVE_DYLIBS/REMOVE_RLIBS.
There were places where we were only calling `rm $(call DYLIB,foo)`
even though we really needed to get rid of the whole glob (at least
based on alex's findings on #13753 that removing the symlink does not
suffice).
Therefore rather than peppering the code with the awkward
`rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
`REMOVE_DYLIBS` user function that expands into that when called.
After I adding an analogous `REMOVE_RLIBS`, I changed all of the
existing calls that rm dylibs or rlibs to use these routines
instead.
Note that the latter is not a true refactoring since I may have
changed cases where it was our intent to only remove the sym-link.
(But if that is the case, then we need to more deeply investigate
alex's findings on #13753 where the system was still dynamically
loading up the non-symlinked libraries that it finds on the load
path.)
* Added RPATH_LINK_SEARCH command and use it on Linux.
On some platforms, namely Linux, when you have libboot.so that has
its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
linker still complains when you do the link step and it does not
know where to find libraries that libboot.so depends upon that live
in HOSTDIR (think e.g. librustuv.so).
As far as I can tell, the GNU linker will consult the
LD_LIBRARY_PATH as part of the linking process to find such
libraries. But if you want to be more careful and not override
LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
way to tell the linker where it can find the libraries that
libboot.so needs. The solution to this on Linux is the
`-Wl,-rpath-link` command line option.
However, this command line option does not exist on Mac OS X, (which
appears to be figuring out how to resolve the libboot.dylib
dependency by some other means, perhaps by consulting the rpath
setting within libboot.dylib).
So, in order to abstract over this distinction, I added the
RPATH_LINK_SEARCH macro to the run-make infrastructure and added
calls to it where necessary to get Linux working. On architectures
other than Linux, the macro expands to nothing.
* Disable miscellaneous tests atop stage1.
* An especially interesting instance of the previous bullet point:
Excuse regex from doing rustdoc tests atop stage1.
This was a (nearly-) final step to get `make check-stage1` working
again.
The use of a special-case check for regex here is ugly but is
analogous other similar checks for regex such as the one that landed
in PR #13844.
The way this is written, the user will get a reminder that
doc-crate-regex is being skipped whenever their rules attempt to do
the crate documentation tests. This is deliberate: I want people
running `make check-stage1` to be reminded about which cases are
being skipped. (But if such echo noise is considered offensive, it
can obviously be removed.)
* Got windows working with the above changes.
This portion of the commit is a cleanup revision of the (previously
mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
setup and extension is handled in order to accommodate Windows' (1.)
use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
entries (problematic for make and for interoperation with tools at
the shell).
* In addition, since the code has been rearchitected to pass the
HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
environment-variable setting command, there is no need to for the
convert_path_spec calls in maketest.py, which in fact were put in
place to placate Windows but were now causing the Windows builds to
fail. Instead we just convert the paths to absolute paths just like
all of the other path arguments.
Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).
2014-04-25 11:22:23 -05:00
|
|
|
|
2020-07-02 13:27:15 -05:00
|
|
|
# diff with common flags for multi-platform diffs against text output
|
|
|
|
DIFF := diff -u --strip-trailing-cr
|
|
|
|
|
2021-02-05 19:50:37 -06:00
|
|
|
# Some of the Rust CI platforms use `/bin/dash` to run `shell` script in
|
|
|
|
# Makefiles. Other platforms, including many developer platforms, default to
|
|
|
|
# `/bin/bash`. (In many cases, `make` is actually using `/bin/sh`, but `sh`
|
|
|
|
# is configured to execute one or the other shell binary). `dash` features
|
|
|
|
# support only a small subset of `bash` features, so `dash` can be thought of as
|
|
|
|
# the lowest common denominator, and tests should be validated against `dash`
|
|
|
|
# whenever possible. Most developer platforms include `/bin/dash`, but to ensure
|
|
|
|
# tests still work when `/bin/dash`, if not available, this `SHELL` override is
|
|
|
|
# conditional:
|
2021-02-13 02:14:50 -06:00
|
|
|
ifndef IS_WINDOWS # dash interprets backslashes in executable paths incorrectly
|
2021-02-05 19:50:37 -06:00
|
|
|
ifneq (,$(wildcard /bin/dash))
|
2021-02-03 18:26:25 -06:00
|
|
|
SHELL := /bin/dash
|
2021-02-05 19:50:37 -06:00
|
|
|
endif
|
2021-02-13 02:14:50 -06:00
|
|
|
endif
|
2021-02-03 18:26:25 -06:00
|
|
|
|
Refactoring: Introduce distinct host and target rpath var setters.
Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.
`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building). Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"
What this commit does:
* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
to `maketest.py`
* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
Instead, it passes along the HOST and TARGET rpath setup vars in
environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`
* Also, pass the current stage number to maketest.py; it in turn
passes it (via an env var) to run-make tests.
This allows the run-make tests to selectively change behavior
(e.g. turn themselves off) to deal with incompatibilities with
e.g. stage1.
* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
and the file to generate to drive that command (`RUN_BINFILE`). The
main thing this enables is that `RUN` can now setup the
`TARGET_RPATH_ENV` without having to dirty up the runner code in
each of the `run-make` Makefiles.
* Cleanup: Factored out commands to delete dylib/rlib into
REMOVE_DYLIBS/REMOVE_RLIBS.
There were places where we were only calling `rm $(call DYLIB,foo)`
even though we really needed to get rid of the whole glob (at least
based on alex's findings on #13753 that removing the symlink does not
suffice).
Therefore rather than peppering the code with the awkward
`rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
`REMOVE_DYLIBS` user function that expands into that when called.
After I adding an analogous `REMOVE_RLIBS`, I changed all of the
existing calls that rm dylibs or rlibs to use these routines
instead.
Note that the latter is not a true refactoring since I may have
changed cases where it was our intent to only remove the sym-link.
(But if that is the case, then we need to more deeply investigate
alex's findings on #13753 where the system was still dynamically
loading up the non-symlinked libraries that it finds on the load
path.)
* Added RPATH_LINK_SEARCH command and use it on Linux.
On some platforms, namely Linux, when you have libboot.so that has
its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
linker still complains when you do the link step and it does not
know where to find libraries that libboot.so depends upon that live
in HOSTDIR (think e.g. librustuv.so).
As far as I can tell, the GNU linker will consult the
LD_LIBRARY_PATH as part of the linking process to find such
libraries. But if you want to be more careful and not override
LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
way to tell the linker where it can find the libraries that
libboot.so needs. The solution to this on Linux is the
`-Wl,-rpath-link` command line option.
However, this command line option does not exist on Mac OS X, (which
appears to be figuring out how to resolve the libboot.dylib
dependency by some other means, perhaps by consulting the rpath
setting within libboot.dylib).
So, in order to abstract over this distinction, I added the
RPATH_LINK_SEARCH macro to the run-make infrastructure and added
calls to it where necessary to get Linux working. On architectures
other than Linux, the macro expands to nothing.
* Disable miscellaneous tests atop stage1.
* An especially interesting instance of the previous bullet point:
Excuse regex from doing rustdoc tests atop stage1.
This was a (nearly-) final step to get `make check-stage1` working
again.
The use of a special-case check for regex here is ugly but is
analogous other similar checks for regex such as the one that landed
in PR #13844.
The way this is written, the user will get a reminder that
doc-crate-regex is being skipped whenever their rules attempt to do
the crate documentation tests. This is deliberate: I want people
running `make check-stage1` to be reminded about which cases are
being skipped. (But if such echo noise is considered offensive, it
can obviously be removed.)
* Got windows working with the above changes.
This portion of the commit is a cleanup revision of the (previously
mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
setup and extension is handled in order to accommodate Windows' (1.)
use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
entries (problematic for make and for interoperation with tools at
the shell).
* In addition, since the code has been rearchitected to pass the
HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
environment-variable setting command, there is no need to for the
convert_path_spec calls in maketest.py, which in fact were put in
place to placate Windows but were now causing the Windows builds to
fail. Instead we just convert the paths to absolute paths just like
all of the other path arguments.
Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).
2014-04-25 11:22:23 -05:00
|
|
|
# This is the name of the binary we will generate and run; use this
|
|
|
|
# e.g. for `$(CC) -o $(RUN_BINFILE)`.
|
|
|
|
RUN_BINFILE = $(TMPDIR)/$(1)
|
|
|
|
|
2022-11-03 10:04:07 -05:00
|
|
|
# Invoke the generated binary on the remote machine if compiletest was
|
|
|
|
# configured to use a remote test device, otherwise run it on the current host.
|
|
|
|
ifdef REMOTE_TEST_CLIENT
|
2022-09-26 05:59:22 -05:00
|
|
|
# FIXME: if a test requires additional files, this will need to be changed to
|
|
|
|
# also push them (by changing the 0 to the number of additional files, and
|
|
|
|
# providing the path of the additional files as the last arguments).
|
|
|
|
EXECUTE = $(REMOTE_TEST_CLIENT) run 0 $(RUN_BINFILE)
|
|
|
|
else
|
|
|
|
EXECUTE = $(RUN_BINFILE)
|
|
|
|
endif
|
|
|
|
|
Refactoring: Introduce distinct host and target rpath var setters.
Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.
`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building). Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"
What this commit does:
* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
to `maketest.py`
* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
Instead, it passes along the HOST and TARGET rpath setup vars in
environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`
* Also, pass the current stage number to maketest.py; it in turn
passes it (via an env var) to run-make tests.
This allows the run-make tests to selectively change behavior
(e.g. turn themselves off) to deal with incompatibilities with
e.g. stage1.
* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
and the file to generate to drive that command (`RUN_BINFILE`). The
main thing this enables is that `RUN` can now setup the
`TARGET_RPATH_ENV` without having to dirty up the runner code in
each of the `run-make` Makefiles.
* Cleanup: Factored out commands to delete dylib/rlib into
REMOVE_DYLIBS/REMOVE_RLIBS.
There were places where we were only calling `rm $(call DYLIB,foo)`
even though we really needed to get rid of the whole glob (at least
based on alex's findings on #13753 that removing the symlink does not
suffice).
Therefore rather than peppering the code with the awkward
`rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
`REMOVE_DYLIBS` user function that expands into that when called.
After I adding an analogous `REMOVE_RLIBS`, I changed all of the
existing calls that rm dylibs or rlibs to use these routines
instead.
Note that the latter is not a true refactoring since I may have
changed cases where it was our intent to only remove the sym-link.
(But if that is the case, then we need to more deeply investigate
alex's findings on #13753 where the system was still dynamically
loading up the non-symlinked libraries that it finds on the load
path.)
* Added RPATH_LINK_SEARCH command and use it on Linux.
On some platforms, namely Linux, when you have libboot.so that has
its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
linker still complains when you do the link step and it does not
know where to find libraries that libboot.so depends upon that live
in HOSTDIR (think e.g. librustuv.so).
As far as I can tell, the GNU linker will consult the
LD_LIBRARY_PATH as part of the linking process to find such
libraries. But if you want to be more careful and not override
LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
way to tell the linker where it can find the libraries that
libboot.so needs. The solution to this on Linux is the
`-Wl,-rpath-link` command line option.
However, this command line option does not exist on Mac OS X, (which
appears to be figuring out how to resolve the libboot.dylib
dependency by some other means, perhaps by consulting the rpath
setting within libboot.dylib).
So, in order to abstract over this distinction, I added the
RPATH_LINK_SEARCH macro to the run-make infrastructure and added
calls to it where necessary to get Linux working. On architectures
other than Linux, the macro expands to nothing.
* Disable miscellaneous tests atop stage1.
* An especially interesting instance of the previous bullet point:
Excuse regex from doing rustdoc tests atop stage1.
This was a (nearly-) final step to get `make check-stage1` working
again.
The use of a special-case check for regex here is ugly but is
analogous other similar checks for regex such as the one that landed
in PR #13844.
The way this is written, the user will get a reminder that
doc-crate-regex is being skipped whenever their rules attempt to do
the crate documentation tests. This is deliberate: I want people
running `make check-stage1` to be reminded about which cases are
being skipped. (But if such echo noise is considered offensive, it
can obviously be removed.)
* Got windows working with the above changes.
This portion of the commit is a cleanup revision of the (previously
mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
setup and extension is handled in order to accommodate Windows' (1.)
use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
entries (problematic for make and for interoperation with tools at
the shell).
* In addition, since the code has been rearchitected to pass the
HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
environment-variable setting command, there is no need to for the
convert_path_spec calls in maketest.py, which in fact were put in
place to placate Windows but were now causing the Windows builds to
fail. Instead we just convert the paths to absolute paths just like
all of the other path arguments.
Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).
2014-04-25 11:22:23 -05:00
|
|
|
# RUN and FAIL are basic way we will invoke the generated binary. On
|
|
|
|
# non-windows platforms, they set the LD_LIBRARY_PATH environment
|
|
|
|
# variable before running the binary.
|
2013-11-16 19:07:32 -06:00
|
|
|
|
|
|
|
RLIB_GLOB = lib$(1)*.rlib
|
2014-04-27 02:52:36 -05:00
|
|
|
BIN = $(1)
|
2013-11-16 19:07:32 -06:00
|
|
|
|
2014-04-27 02:52:36 -05:00
|
|
|
UNAME = $(shell uname)
|
|
|
|
|
|
|
|
ifeq ($(UNAME),Darwin)
|
2022-09-26 05:59:22 -05:00
|
|
|
RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
|
|
|
|
FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
|
2013-11-16 19:07:32 -06:00
|
|
|
DYLIB_GLOB = lib$(1)*.dylib
|
|
|
|
DYLIB = $(TMPDIR)/lib$(1).dylib
|
2015-08-26 18:57:56 -05:00
|
|
|
STATICLIB = $(TMPDIR)/lib$(1).a
|
|
|
|
STATICLIB_GLOB = lib$(1)*.a
|
2013-11-16 19:07:32 -06:00
|
|
|
else
|
2014-04-27 02:52:36 -05:00
|
|
|
ifdef IS_WINDOWS
|
2022-09-26 05:59:22 -05:00
|
|
|
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE)
|
|
|
|
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE) && exit 1 || exit 0
|
2014-04-27 02:52:36 -05:00
|
|
|
DYLIB_GLOB = $(1)*.dll
|
|
|
|
DYLIB = $(TMPDIR)/$(1).dll
|
2020-04-08 14:36:18 -05:00
|
|
|
ifdef IS_MSVC
|
2015-08-26 18:57:56 -05:00
|
|
|
STATICLIB = $(TMPDIR)/$(1).lib
|
|
|
|
STATICLIB_GLOB = $(1)*.lib
|
2020-04-08 14:36:18 -05:00
|
|
|
else
|
2020-07-03 14:00:14 -05:00
|
|
|
IMPLIB = $(TMPDIR)/lib$(1).dll.a
|
2020-04-08 14:36:18 -05:00
|
|
|
STATICLIB = $(TMPDIR)/lib$(1).a
|
|
|
|
STATICLIB_GLOB = lib$(1)*.a
|
|
|
|
endif
|
2014-04-27 02:52:36 -05:00
|
|
|
BIN = $(1).exe
|
2019-04-25 08:30:23 -05:00
|
|
|
LLVM_FILECHECK := $(shell cygpath -u "$(LLVM_FILECHECK)")
|
2014-04-27 02:52:36 -05:00
|
|
|
else
|
2022-09-26 05:59:22 -05:00
|
|
|
RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
|
|
|
|
FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
|
2013-11-16 19:07:32 -06:00
|
|
|
DYLIB_GLOB = lib$(1)*.so
|
|
|
|
DYLIB = $(TMPDIR)/lib$(1).so
|
2015-08-26 18:57:56 -05:00
|
|
|
STATICLIB = $(TMPDIR)/lib$(1).a
|
|
|
|
STATICLIB_GLOB = lib$(1)*.a
|
|
|
|
endif
|
2013-11-16 19:07:32 -06:00
|
|
|
endif
|
2015-08-26 18:57:56 -05:00
|
|
|
|
|
|
|
ifdef IS_MSVC
|
|
|
|
COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2)
|
2019-10-25 20:47:06 -05:00
|
|
|
COMPILE_OBJ_CXX = $(CXX) -EHs -c -Fo:`cygpath -w $(1)` $(2)
|
2015-08-26 18:57:56 -05:00
|
|
|
NATIVE_STATICLIB_FILE = $(1).lib
|
|
|
|
NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1))
|
|
|
|
OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \
|
|
|
|
-Fo:`cygpath -w $(TMPDIR)/$(1).obj`
|
|
|
|
else
|
2022-07-01 15:01:41 -05:00
|
|
|
COMPILE_OBJ = $(CC) -v -c -o $(1) $(2)
|
2018-05-02 03:26:00 -05:00
|
|
|
COMPILE_OBJ_CXX = $(CXX) -c -o $(1) $(2)
|
2015-08-26 18:57:56 -05:00
|
|
|
NATIVE_STATICLIB_FILE = lib$(1).a
|
|
|
|
NATIVE_STATICLIB = $(call STATICLIB,$(1))
|
|
|
|
OUT_EXE=-o $(TMPDIR)/$(1)
|
2014-04-27 02:52:36 -05:00
|
|
|
endif
|
2013-11-16 19:07:32 -06:00
|
|
|
|
2015-08-26 18:57:56 -05:00
|
|
|
|
2014-06-06 19:48:46 -05:00
|
|
|
# Extra flags needed to compile a working executable with the standard library
|
|
|
|
ifdef IS_WINDOWS
|
2015-08-26 18:57:56 -05:00
|
|
|
ifdef IS_MSVC
|
2023-03-20 19:08:30 -05:00
|
|
|
EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib bcrypt.lib ntdll.lib
|
2015-08-26 18:57:56 -05:00
|
|
|
else
|
2023-03-20 19:08:30 -05:00
|
|
|
EXTRACFLAGS := -lws2_32 -luserenv -lbcrypt -lntdll
|
2019-10-22 08:12:33 -05:00
|
|
|
EXTRACXXFLAGS := -lstdc++
|
2019-10-26 11:41:55 -05:00
|
|
|
# So this is a bit hacky: we can't use the DLL version of libstdc++ because
|
|
|
|
# it pulls in the DLL version of libgcc, which means that we end up with 2
|
|
|
|
# instances of the DW2 unwinding implementation. This is a problem on
|
|
|
|
# i686-pc-windows-gnu because each module (DLL/EXE) needs to register its
|
|
|
|
# unwind information with the unwinding implementation, and libstdc++'s
|
|
|
|
# __cxa_throw won't see the unwinding info we registered with our statically
|
|
|
|
# linked libgcc.
|
|
|
|
#
|
|
|
|
# Now, simply statically linking libstdc++ would fix this problem, except
|
|
|
|
# that it is compiled with the expectation that pthreads is dynamically
|
|
|
|
# linked as a DLL and will fail to link with a statically linked libpthread.
|
|
|
|
#
|
2021-10-28 16:38:21 -05:00
|
|
|
# So we end up with the following hack: we link use static:-bundle to only
|
2019-10-26 11:41:55 -05:00
|
|
|
# link the parts of libstdc++ that we actually use, which doesn't include
|
|
|
|
# the dependency on the pthreads DLL.
|
2022-04-08 10:20:57 -05:00
|
|
|
EXTRARSCXXFLAGS := -l static:-bundle=stdc++
|
2015-08-26 18:57:56 -05:00
|
|
|
endif
|
2014-06-06 19:48:46 -05:00
|
|
|
else
|
2015-03-23 14:48:42 -05:00
|
|
|
ifeq ($(UNAME),Darwin)
|
2017-04-27 11:58:52 -05:00
|
|
|
EXTRACFLAGS := -lresolv
|
2019-11-03 05:23:44 -06:00
|
|
|
EXTRACXXFLAGS := -lc++
|
|
|
|
EXTRARSCXXFLAGS := -lc++
|
2014-06-06 19:48:46 -05:00
|
|
|
else
|
2015-03-23 14:48:42 -05:00
|
|
|
ifeq ($(UNAME),FreeBSD)
|
2014-06-06 19:48:46 -05:00
|
|
|
EXTRACFLAGS := -lm -lpthread -lgcc_s
|
2015-02-02 13:04:58 -06:00
|
|
|
else
|
2016-01-21 10:30:22 -06:00
|
|
|
ifeq ($(UNAME),SunOS)
|
2017-08-03 17:38:34 -05:00
|
|
|
EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv
|
2016-01-21 10:30:22 -06:00
|
|
|
else
|
2015-03-23 14:48:42 -05:00
|
|
|
ifeq ($(UNAME),OpenBSD)
|
2017-11-26 03:08:25 -06:00
|
|
|
EXTRACFLAGS := -lm -lpthread -lc++abi
|
2015-12-19 11:00:23 -06:00
|
|
|
RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))"
|
2014-06-06 19:48:46 -05:00
|
|
|
else
|
|
|
|
EXTRACFLAGS := -lm -lrt -ldl -lpthread
|
2015-03-23 14:48:42 -05:00
|
|
|
EXTRACXXFLAGS := -lstdc++
|
2019-10-26 11:41:55 -05:00
|
|
|
EXTRARSCXXFLAGS := -lstdc++
|
2015-03-23 14:48:42 -05:00
|
|
|
endif
|
2014-06-06 19:48:46 -05:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2015-01-29 01:19:28 -06:00
|
|
|
endif
|
2014-06-06 19:48:46 -05:00
|
|
|
|
Refactoring: Introduce distinct host and target rpath var setters.
Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.
`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building). Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"
What this commit does:
* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
to `maketest.py`
* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
Instead, it passes along the HOST and TARGET rpath setup vars in
environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`
* Also, pass the current stage number to maketest.py; it in turn
passes it (via an env var) to run-make tests.
This allows the run-make tests to selectively change behavior
(e.g. turn themselves off) to deal with incompatibilities with
e.g. stage1.
* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
and the file to generate to drive that command (`RUN_BINFILE`). The
main thing this enables is that `RUN` can now setup the
`TARGET_RPATH_ENV` without having to dirty up the runner code in
each of the `run-make` Makefiles.
* Cleanup: Factored out commands to delete dylib/rlib into
REMOVE_DYLIBS/REMOVE_RLIBS.
There were places where we were only calling `rm $(call DYLIB,foo)`
even though we really needed to get rid of the whole glob (at least
based on alex's findings on #13753 that removing the symlink does not
suffice).
Therefore rather than peppering the code with the awkward
`rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
`REMOVE_DYLIBS` user function that expands into that when called.
After I adding an analogous `REMOVE_RLIBS`, I changed all of the
existing calls that rm dylibs or rlibs to use these routines
instead.
Note that the latter is not a true refactoring since I may have
changed cases where it was our intent to only remove the sym-link.
(But if that is the case, then we need to more deeply investigate
alex's findings on #13753 where the system was still dynamically
loading up the non-symlinked libraries that it finds on the load
path.)
* Added RPATH_LINK_SEARCH command and use it on Linux.
On some platforms, namely Linux, when you have libboot.so that has
its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
linker still complains when you do the link step and it does not
know where to find libraries that libboot.so depends upon that live
in HOSTDIR (think e.g. librustuv.so).
As far as I can tell, the GNU linker will consult the
LD_LIBRARY_PATH as part of the linking process to find such
libraries. But if you want to be more careful and not override
LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
way to tell the linker where it can find the libraries that
libboot.so needs. The solution to this on Linux is the
`-Wl,-rpath-link` command line option.
However, this command line option does not exist on Mac OS X, (which
appears to be figuring out how to resolve the libboot.dylib
dependency by some other means, perhaps by consulting the rpath
setting within libboot.dylib).
So, in order to abstract over this distinction, I added the
RPATH_LINK_SEARCH macro to the run-make infrastructure and added
calls to it where necessary to get Linux working. On architectures
other than Linux, the macro expands to nothing.
* Disable miscellaneous tests atop stage1.
* An especially interesting instance of the previous bullet point:
Excuse regex from doing rustdoc tests atop stage1.
This was a (nearly-) final step to get `make check-stage1` working
again.
The use of a special-case check for regex here is ugly but is
analogous other similar checks for regex such as the one that landed
in PR #13844.
The way this is written, the user will get a reminder that
doc-crate-regex is being skipped whenever their rules attempt to do
the crate documentation tests. This is deliberate: I want people
running `make check-stage1` to be reminded about which cases are
being skipped. (But if such echo noise is considered offensive, it
can obviously be removed.)
* Got windows working with the above changes.
This portion of the commit is a cleanup revision of the (previously
mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
setup and extension is handled in order to accommodate Windows' (1.)
use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
entries (problematic for make and for interoperation with tools at
the shell).
* In addition, since the code has been rearchitected to pass the
HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
environment-variable setting command, there is no need to for the
convert_path_spec calls in maketest.py, which in fact were put in
place to placate Windows but were now causing the Windows builds to
fail. Instead we just convert the paths to absolute paths just like
all of the other path arguments.
Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).
2014-04-25 11:22:23 -05:00
|
|
|
REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
|
|
|
|
REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
|
|
|
|
|
2013-11-16 19:07:32 -06:00
|
|
|
%.a: %.o
|
2017-10-10 15:06:22 -05:00
|
|
|
$(AR) crus $@ $<
|
2015-12-14 17:40:43 -06:00
|
|
|
ifdef IS_MSVC
|
|
|
|
%.lib: lib%.o
|
|
|
|
$(MSVC_LIB) -out:`cygpath -w $@` $<
|
|
|
|
else
|
2015-08-26 18:57:56 -05:00
|
|
|
%.lib: lib%.o
|
2017-10-10 15:06:22 -05:00
|
|
|
$(AR) crus $@ $<
|
2015-12-14 17:40:43 -06:00
|
|
|
endif
|
2013-11-16 19:07:32 -06:00
|
|
|
%.dylib: %.o
|
2013-11-28 20:03:38 -06:00
|
|
|
$(CC) -dynamiclib -Wl,-dylib -o $@ $<
|
2013-11-16 19:07:32 -06:00
|
|
|
%.so: %.o
|
2013-11-28 20:03:38 -06:00
|
|
|
$(CC) -o $@ $< -shared
|
2015-08-26 18:57:56 -05:00
|
|
|
|
|
|
|
ifdef IS_MSVC
|
|
|
|
%.dll: lib%.o
|
|
|
|
$(CC) $< -link -dll -out:`cygpath -w $@`
|
|
|
|
else
|
2014-04-27 02:52:36 -05:00
|
|
|
%.dll: lib%.o
|
2020-06-13 07:18:02 -05:00
|
|
|
$(CC) -o $@ $< -shared -Wl,--out-implib=$@.a
|
2015-08-26 18:57:56 -05:00
|
|
|
endif
|
2014-04-27 02:52:36 -05:00
|
|
|
|
2013-11-16 19:07:32 -06:00
|
|
|
$(TMPDIR)/lib%.o: %.c
|
2015-08-26 18:57:56 -05:00
|
|
|
$(call COMPILE_OBJ,$@,$<)
|