internal/build:compile with c mode,when c file

This commit is contained in:
luoliwoshang
2025-06-12 11:52:41 +08:00
parent 9001cdb8f2
commit 93197e7621
20 changed files with 20 additions and 50 deletions

View File

@@ -953,6 +953,13 @@ func clFiles(ctx *context, files string, pkg *packages.Package, procFile func(li
func clFile(ctx *context, args []string, cFile, expFile string, procFile func(linkFile string), verbose bool) {
llFile := expFile + filepath.Base(cFile) + ".ll"
ext := filepath.Ext(cFile)
// default clang++ will use c++ to compile c file,will cause symbol be mangled
if ext == ".c" {
args = append(args, "-x", "c")
}
args = append(args, "-emit-llvm", "-S", "-o", llFile, "-c", cFile)
args = append(args, ctx.crossCompile.CCFLAGS...)
args = append(args, ctx.crossCompile.CFLAGS...)