build native/wasi with clang++ and keep embed building with clang

This commit is contained in:
Li Jie
2025-08-16 10:49:00 +08:00
parent 21174e44bb
commit b831952e2e

View File

@@ -70,7 +70,7 @@ func getESPClangRoot() (clangRoot string, err error) {
// Try to download ESP Clang if platform is supported
platformSuffix := getESPClangPlatform(runtime.GOOS, runtime.GOARCH)
if platformSuffix != "" {
cacheClangDir := filepath.Join(env.LLGoCacheDir(), "crosscompile", "clang-"+espClangVersion)
cacheClangDir := filepath.Join(env.LLGoCacheDir(), "crosscompile", "esp-clang-"+espClangVersion)
if _, err = os.Stat(cacheClangDir); err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return
@@ -119,6 +119,16 @@ func use(goos, goarch string, wasiThreads bool) (export Export, err error) {
targetTriple := llvm.GetTargetTriple(goos, goarch)
llgoRoot := env.LLGoROOT()
// Check for ESP Clang support for target-based builds
clangRoot, err := getESPClangRoot()
if err != nil {
return
}
// Set ClangRoot and CC if clang is available
export.ClangRoot = clangRoot
export.CC = filepath.Join(clangRoot, "bin", "clang++")
if runtime.GOOS == goos && runtime.GOARCH == goarch {
// not cross compile
// Set up basic flags for non-cross-compile
@@ -312,7 +322,7 @@ func useTarget(targetName string) (export Export, err error) {
// Set ClangRoot and CC if clang is available
export.ClangRoot = clangRoot
export.CC = filepath.Join(clangRoot, "bin", "clang")
export.CC = filepath.Join(clangRoot, "bin", "clang++")
// Convert target config to Export - only export necessary fields
export.BuildTags = config.BuildTags