Open jpeach opened 3 years ago
Yeah, I think -frewrite-includes
would work for us, but I'm not sure if there's an easy way to autodetect which one to use. Could add another configuration flag, I guess -- LLAMACC_CC_IS_CLANG
or something -- but that seems mildly unpleasant
FWIW, I tried this quick hack with the Envoy build, and it ended up not being able to resolve libstdc++ types properly. Not sure whether there's something more needed to get partial pre-processing to work with clang, or whether this Bael making some aggressive assumptions.
--- cmd/llamacc/main.go
+++ cmd/llamacc/main.go
@@ -196,7 +196,7 @@ func buildLocalPreprocess(ctx context.Context, client *daemon.Client, cfg *Confi
preprocessor.Args = []string{comp.LocalCompiler(cfg)}
preprocessor.Args = append(preprocessor.Args, comp.LocalArgs...)
if !cfg.FullPreprocess {
- preprocessor.Args = append(preprocessor.Args, "-fdirectives-only")
+ preprocessor.Args = append(preprocessor.Args, "-frewrite-includes")
}
preprocessor.Args = append(preprocessor.Args, "-E", "-o", "-", comp.Input)
preprocessor.Stdout = &preprocessed
@@ -224,7 +224,7 @@ func buildLocalPreprocess(ctx context.Context, client *daemon.Client, cfg *Confi
args.Args = []string{comp.RemoteCompiler(cfg)}
args.Args = append(args.Args, comp.RemoteArgs...)
if !cfg.FullPreprocess {
- args.Args = append(args.Args, "-fdirectives-only", "-fpreprocessed")
+ args.Args = append(args.Args, "-frewrite-includes")
}
args.Args = append(args.Args, "-x", comp.PreprocessedLanguage, "-o", comp.Output, "-")
OK, I figured this one out. We need to pass all the Defs along to the remote build as well as the -frewrite-includes
flag. Clang also needs different constants in preprocessedLang
(ie. "c" and "c++").
This one made me scratch my head a bit because I assumed it was a Bazel problem and didn't look in the llama docs for it :joy:
-fdirectives-only
doesn't work with clang. Perhaps there's an alternative that works with both compilers? There is a short thread discussing how clang's-frewrite-includes
differs, but maybe the difference doesn't matter for llama?