yrnkrn / zapcc

zapcc is a caching C++ compiler based on clang, designed to perform faster compilations
Other
1.25k stars 61 forks source link

May be simpler example for #12 #13

Closed yrnkrn closed 6 years ago

yrnkrn commented 6 years ago

I think this is the same issue,

a.h:

#pragma once
struct A {};

reduced_boost.h:

#pragma once
template <class A> void void_cast_register() __attribute__((__used__));
template <class A> void void_cast_register() {}

file1.cpp:

#include "a.h"
#include "reduced_boost.h"
void foo1() { void_cast_register<A>(); }

file2.cpp:

#include "reduced_boost.h"

runme.sh:

#!/bin/bash
zapcc -cc1 -reset-server
set -xu
clear
FLAGS="-c -std=c++11 -target x86_64-unknown-linux-gnu file1.cpp file2.cpp"
L="llvm-nm file2.o"
clang $FLAGS
$L
rm -fr *.o*
zapcc $FLAGS
$L
rm -fr *.o*

output:

+ FLAGS='-c -std=c++11 -target x86_64-unknown-linux-gnu file1.cpp file2.cpp'
+ L='llvm-nm file2.o'
+ clang -c -std=c++11 -target x86_64-unknown-linux-gnu file1.cpp file2.cpp
+ llvm-nm file2.o
+ rm -fr file1.o file2.o
+ zapcc -c -std=c++11 -target x86_64-unknown-linux-gnu file1.cpp file2.cpp
+ llvm-nm file2.o
0000000000000000 W _Z18void_cast_registerI1AEvv
+ rm -fr file1.o file2.o

I'll start with this and see if it solves #12 as well.

yrnkrn commented 6 years ago

13.zip

Probably has to do with the __attribute__((__used__)).

yrnkrn commented 6 years ago

Fix + new LIT test in 194583e73b0dde257b49f41426c5bc66229baba5.