Joel Rosdahl [Tue, 1 Sep 2020 17:48:24 +0000 (19:48 +0200)]
Improve test cases that use objdump
- Added expect_objdump_contains and expect_objdump_not_contains utility
functions to the main test framework, making objdump_cmd and grep_cmd
(renamed to objdump_grep_cmd) internal utility functions.
- Removed strange support for the $HOST_OS_WINDOWS || $HOST_OS_CYGWIN
case in objdump_grep_cmd. Let’s re-add it later if and when it becomes
a problem.
- objdump_grep_cmd now greps for literal strings, thus no longer
interpreting $PWD as a regex.
- Made test cases use expect_objdump_(not_)contains instead of
“objdump_grep_cmd | grep_cmd”.
Joel Rosdahl [Tue, 1 Sep 2020 14:51:32 +0000 (16:51 +0200)]
Fix debug_prefix_map failure with old objdump versions
“objdump -g” does not list debug info like the “Multiple
-fdebug-prefix-map” test expects when using objdump 2.20, e.g. on CentOS
6. “objdump -W” does however work, and it seems to work for object files
with compressed .debug_str section as well.
Joel Rosdahl [Mon, 31 Aug 2020 08:30:38 +0000 (10:30 +0200)]
Improve handling of ccache version in the source release archive
The version.cpp file is currently generated in the source directory.
This is a bit unclean since generated files are supposed to be put in
the build directory.
Also, when building from a source release archive outside a Git
repository the CMake scripts still try to get the version from Git and
then emit an ugly warning message:
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
CMake Warning at cmake/GenerateVersionFile.cmake:42 (message):
Running git failed
Call Stack (most recent call first):
cmake/GenerateVersionFile.cmake:50 (get_version_from_git)
CMakeLists.txt:32 (include)
Fix this by including a VERSION file in the source release archive. If
the VERSION file exists, GenerateVersionFile.cmake just uses the version
from the file and doesn’t try to get a version from Git. If the file
doesn’t exist, the version is looked up from Git like before, but it’s a
fatal error if the version cannot be determined.
Rafael Kitover [Thu, 27 Aug 2020 19:23:26 +0000 (19:23 +0000)]
Support building on MSVC (#632)
With these changes, the project builds with Visual Studio 2019, unit
tests pass and it works correctly with mingw gcc.
NOTE: The very latest version of Visual Studio 2019 is required, because
there was just a necessary fix for template arguments.
Tested building and running unit tests on Windows+MSVC, Windows+MinGW,
Linux and macOS.
- Enable `ZSTD_FROM_INTERNET` by default for MSVC when not using vcpkg
or conan.
- Add include tests for some standard UNIX headers not available on
MSVC.
- Add necessary MSVC compiler flags.
- In `Args::from_gcc_atfile()` iterate over the string via `c_str()`
instead of `cbegin()`, the MSVC string character iterator does not
include the ending null byte.
- Misc. minor cmake fix-ups.
- Add some headers that are not implicitly included from other headers
like `<algorithm>`, `<ios>`, `<cstdint>` and `<cstdarg>` in some
places, gcc does this but MSVC does not.
- Add `std::filesystem` version of `Util::traverse()` when dirent.h is
not available, which is preferred for performance reasons.
- Add implementations of the following functions that are not available
in MSVC in Win32Util.cpp: `gettimeofday()`, `localtime_r()`,
`asprintf()`.
- Add Windows implementation of `getopt_long()` from
https://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso
to third_party/win32.
- Add some compatibility typedefs, constants and macros to the `_WIN32`
section of system.hpp, as well as the prototypes for the functions
added to Win32Util.cpp.
- Fix up unit tests expecting '/' separated paths to expect paths
delimited by `DIR_DELIM_CH`.
- Invoke test/run with bash from cmake, necessary on msys2+mingw64, many
fail, there is more work to do here.
- Set the warning level to `/W4` and silence all the uninteresting
warning types. Compiles with no warnings now.
- Switch to using standard C++ attributes `[[nodiscard]]` and
`[[maybe_unused]]` and define macros for gcc for their equivalents.
- `#define DOCTEST_CONFIG_USE_STD_HEADERS` for MSVC only, because it
requires explicitly including `<ostream>`.
- Add vim files to .gitignore.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Alexander Lanin [Thu, 27 Aug 2020 19:18:56 +0000 (21:18 +0200)]
Fix asm compiler detection (#644)
CMake requires ASM to be the last parameter so it can try whether the C compiler can compile asm.
See https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1560/diffs
Joel Rosdahl [Sun, 23 Aug 2020 18:11:30 +0000 (20:11 +0200)]
build.yaml: Use build type CI by default
I think that it makes sense to use a ccache binary built in release mode
in CI tests by default since that is what the end user will actually
run. At the same time we want to test assertions in CI, so use the CI
build type which is RelWithDebInfo but without -DNDEBUG. I here assume
that the difference between -O3 (from build type Release) and -O2 (from
build type RelWithDebInfo) is small.
Changed OS to Ubuntu 20.04 for “Linux MinGW 64-bit” since the cross
compiler in Ubuntu 18.04 is buggy.
Joel Rosdahl [Sat, 22 Aug 2020 17:58:12 +0000 (19:58 +0200)]
Rename cmake_build.yml to build.yaml
- Remove “cmake_” prefix since it’s a redundant implementation detail.
- Use “.yaml” instead of “.yml” since that’s the officially recommended
YAML extension.
Joel Rosdahl [Tue, 11 Aug 2020 19:05:15 +0000 (21:05 +0200)]
Add new absolute_paths_in_stderr (CCACHE_ABSSTDERR) feature
Motivation for the feature: When using the “Unix Makefiles” generator
with CMake, the compiler is executed in a different CWD than the “make”
command. This works well since absolute paths are passed to the
compiler. But combined with ccache’s base_dir feature the paths in
compiler error or warning messages will be incorrect since they will be
relative to the CWD of the compiler, not the CWD where the user or IDE
ran “make”. absolute_paths_in_stderr helps with this problem by
rewriting relative paths to absolute paths in the compiler’s stderr
output so that the user or IDE will see valid paths.
Joel Rosdahl [Sat, 8 Aug 2020 18:41:18 +0000 (20:41 +0200)]
Use XDG base directories by default
ccache will now follow the XDG Base Directory Specification
(https://specifications.freedesktop.org/basedir-spec/) by default so
that:
- the cache directory is $XDG_CACHE_HOME/ccache (or $HOME/.cache/ccache
if XDG_CACHE_HOME is not set), and
- the (primary) configuration file is
$XDG_CONFIG_HOME/ccache/ccache.conf (or
$HOME/.config/ccache/ccache.conf if XDG_CONFIG_HOME is not set).
On macOS, the fallback cache directory is $HOME/Library/Caches/ccache
and the fallback configuration file is
$HOME/Library/Preferences/ccache/ccache.conf. On Windows, the fallback
cache directory is %APPDATA%/ccache and the fallback configuration file
is %APPDATA%/ccache/ccache.conf.
Exceptions:
1. If CCACHE_CONFIGPATH is set, use that path for the configuration
file.
2. If CCACHE_DIR is set (or ccache_dir in the secondary configuration),
use that path for the cache directory and $CCACHE_DIR/ccache.conf for
the configuration file.
3. If the legacy $HOME/.ccache directory exists, use that cache
directory and $HOME/.ccache/ccache.conf for the configuration file.
Joel Rosdahl [Thu, 6 Aug 2020 14:21:52 +0000 (16:21 +0200)]
Improve building via Docker
- Simplified names (e.g. ubuntu-14-trusty -> ubuntu-14.04,
debian-9-stretch -> debian-9).
- Enabled debian-9 in misc/test-all-systems since it works.
- Renamed centos to centos-7.
- Added centos-8 and fedora-32.
- Updated dockerfiles/README to match reality after the conversion to
CMake.
- Cleaned up Dockerfiles.
- Improved misc/test-all-systems.
- Removed unsupported Clang build for alpine-3.4, centos-7 and
ubuntu-14.04.
Joel Rosdahl [Thu, 6 Aug 2020 08:42:48 +0000 (10:42 +0200)]
color_diagnostics test: Fix race conditions on some platforms
script(1) returns early on some platforms (leaving a child process
living for a short while) and the output may therefore still be pending.
Work around this by sleeping until the output file has content.
Joel Rosdahl [Thu, 6 Aug 2020 07:41:55 +0000 (09:41 +0200)]
CCACHE_PREFIX test: Fix failure for GCC <4.9
The CCACHE_PREFIX test logs execution of prefixes. After 1c6ccf18c2e04459b1ac76ede4580b3ddcd27bbe (#596) the compiler and
prefixes can be run twice if GCC doesn’t support -fdiagnostics-color and
the test case is not prepared for that. Fix this by letting prefix-a
truncate the log file.
Joel Rosdahl [Tue, 4 Aug 2020 19:09:59 +0000 (21:09 +0200)]
Improve Clang modules test suite
- Backdate modified header so that the test actually tests content and
not bails out early due to too new header timestamp.
- Verify that modifications to module.modulemap are detected, which is
key to how the modules support works.
Joel Rosdahl [Tue, 4 Aug 2020 19:07:09 +0000 (21:07 +0200)]
Remove unnecessary compiler behavior test in modules test suite
The “preprocessor output” test in the modules test suite only tests
compiler behavior, and the string it looks for in the preprocessed
output is different for older and newer Clang versions. It seems like a
kind of a probing call, but I don’t see why we would want to probe the
compiler behavior in this case so I’ll just remove it.
Joel Rosdahl [Mon, 3 Aug 2020 05:04:31 +0000 (07:04 +0200)]
C++-ify logging routines
- Simplified and C++-ified logging code.
- Added Logging::log and Logging::bulk_log functions corresponding to
the old cc_log and cc_bulklog functions. The new functions pass their
arguments to fmt::format.
- Replacements:
* init_log → Logging::init
* cc_log → Logging::log
* cc_bulklog → Logging::bulk_log
* cc_log_argv → Logging::log plus Util::format_argv_for_logging
* cc_dump_debug_log_buffer -> Logging::dump_log
- A legacy cc_log implementation is still available so that logging can
be converted gradually to the new functionality.
Joel Rosdahl [Sat, 1 Aug 2020 14:39:11 +0000 (16:39 +0200)]
Let CCACHE_UMASK apply only to files/directories in the cache directory
Ever since the CCACHE_UMASK setting was added in 75dd382407a36b3ebab36bb1027eb43a07498bec it has applied to all files
created by ccache, including files such as the object files and
executables created when ccache is called for linking. This was
presumably the easy thing to do, but it affects the observable output
from the compiler. There are also two related bugs:
1. CCACHE_UMASK is not used when creating the initial configuration file.
2. CCACHE_UMASK is used when creating the log file.
Fix this by:
- saving the original umask in Context,
- introducing a UmaskScope class,
- using UmaskScope objects to set the original umask when calling the
compiler and when copying result files from the cache, and
- setting the umask after creating the log file but before creating the
initial configuration file.