| Issue |
181076
|
| Summary |
Recent modules change caused change in initialization behavior
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
boomanaiden154
|
With the following setup:
```
//--- repro/Makefile
test.o: test.pcm
rm -rf $@
$(CLANG) -Xclang=-fno-cxx-modules -Xclang=-fmodule-map-file-home-is-cwd -fmodules -fno-implicit-modules -fno-implicit-module-maps -Xclang=-fmodule-file=test.pcm -c test.cc -o test.o
test.pcm:
rm -rf $@
$(CLANG) -fmodule-name=test_module -Xclang=-fno-cxx-modules -Xclang=-fmodule-map-file-home-is-cwd -xc++ -Xclang=-emit-module -fmodules -fno-implicit-modules -fno-implicit-module-maps -nostdinc++ -nostdlib++ -c test.cppmap -o test.pcm
.PHONY: clean
clean:
find . \( -name '*.pcm' -o -name '*.o' \) -delete
//--- repro/test.cc
int main() {}
//--- repro/test.cppmap
module "test_module" {
header "test_header.h"
}
//--- repro/test_header.h
extern "C" void exit(int);
namespace {
namespace {
class FooBar {};
namespace foo_namespace {
class RegisterOnce;
template <const FooBar&>
struct FooBarRegisterer {
static const RegisterOnce kRegisterOnce;
};
class RegisterOnce {};
void RegisterFooBarImpl();
template <const FooBar& t>
const RegisterOnce FooBarRegisterer<t>::kRegisterOnce =
(RegisterFooBarImpl(), RegisterOnce());
template <FooBar& tag,
const RegisterOnce& =
FooBarRegisterer<tag>::kRegisterOnce>
FooBar CreateFooBarInternal ;
}
template <FooBar& tag>
FooBar CreateFooBar() {
foo_namespace::CreateFooBarInternal<tag>;
}
FooBar kNullArgumentFooBar =
CreateFooBar<kNullArgumentFooBar>();
namespace foo_namespace {
void RegisterFooBarImpl() {
exit(1);
}
}
}
}
```
and the following interestingness test:
```
#!/bin/bash -e
trap 'make -C repro clean' EXIT
export CLANG=<path to your clang>
make -C repro clean
rm -rf modules-bin
make -C repro
$CLANG -fuse-ld=lld ./repro/test.o -o modules-bin
retVal=0
./modules-bin || retVal=$?
if [ $retVal -ne 1 ]; then
echo "Modules not interesting, exiting"
exit 1
fi
echo "Modules interesting"
rm -rf ./modules-bin
make -C repro clean
file_path=$(grep -m1 -o '.*\.o' ./repro/Makefile)
dir=$(dirname "$file_path")
mkdir -p "./repro/$dir"
nonmodcmd=$(grep -A3 '\.o:' ./repro/Makefile | \
grep '$(CLANG)' | \
sed "s#\$(CLANG)#$CLANG#" | \
sed 's/$(EXTRA_CFLAGS)//' | \
sed -E 's#\S*-fmodule\S+##g')
$(cd repro && ${nonmodcmd})
$CLANG -fuse-ld=lld ./repro/test.o -o modules-bin
./modules-bin
echo "Non-modules interesting"
```
We are seeing changed initialization behavior for the modules build (that seems to be incorrect). This is occurring after 013b345af992f66d5ecfd168844ebfc6956ccae0.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs