1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
SUITE_modules_PROBE() {
if ! $COMPILER_TYPE_CLANG || $COMPILER_USES_MSVC; then
echo "-fmodules/-fcxx-modules not supported by compiler"
else
echo '#include <string>' >testmodules.cpp
$COMPILER -x c++ -fmodules testmodules.cpp -S || echo "compiler does not support modules"
fi
}
SUITE_modules_SETUP() {
unset CCACHE_NODIRECT
export CCACHE_DEPEND=1
cat <<EOF >test1.h
#include <string>
EOF
backdate test1.h
cat <<EOF >module.modulemap
module "Test1" {
header "test1.h"
export *
}
EOF
backdate module.modulemap
cat <<EOF >test1.cpp
#import "test1.h"
int main() { return 0; }
EOF
}
SUITE_modules() {
# -------------------------------------------------------------------------
TEST "fall back to real compiler, no sloppiness"
$CCACHE_COMPILE -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat could_not_use_modules 1
$CCACHE_COMPILE -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat could_not_use_modules 2
# -------------------------------------------------------------------------
TEST "fall back to real compiler, no depend mode"
unset CCACHE_DEPEND
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS modules" $CCACHE_COMPILE -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat could_not_use_modules 1
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS modules" $CCACHE_COMPILE -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat could_not_use_modules 2
# -------------------------------------------------------------------------
TEST "cache hit"
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS modules" $CCACHE_COMPILE -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat direct_cache_hit 0
expect_stat cache_miss 1
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS modules" $CCACHE_COMPILE -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat direct_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "cache miss"
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS modules" $CCACHE_COMPILE -MD -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat cache_miss 1
cat <<EOF >test1.h
#include <string>
void f();
EOF
backdate test1.h
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS modules" $CCACHE_COMPILE -MD -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat cache_miss 2
echo >>module.modulemap
backdate test1.h
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS modules" $CCACHE_COMPILE -MD -x c++ -fmodules -fcxx-modules -c test1.cpp -MD
expect_stat cache_miss 3
}
|