Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/actions/setup-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runs:
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{inputs.llvm-version}} main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y llvm-${{inputs.llvm-version}}-dev clang-${{inputs.llvm-version}} libclang-${{inputs.llvm-version}}-dev lld-${{inputs.llvm-version}} pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev libunwind-dev libuv1-dev
sudo apt-get install -y llvm-${{inputs.llvm-version}}-dev clang-${{inputs.llvm-version}} libclang-${{inputs.llvm-version}}-dev lld-${{inputs.llvm-version}} pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev libunwind-${{inputs.llvm-version}}-dev libuv1-dev libc++-${{inputs.llvm-version}}-dev
echo "PATH=/usr/lib/llvm-${{inputs.llvm-version}}/bin:$PATH" >> $GITHUB_ENV

# Install optional deps for demos.
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/llgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ jobs:
with:
go-version: ${{matrix.go}}

- name: _xtool build tests
run: |
cd _xtool
llgo build -v ./...

- name: Test demos
run: |
# TODO(lijie): force python3-embed to be linked with python-3.12-embed
Expand All @@ -88,6 +83,11 @@ jobs:
export PKG_CONFIG_PATH=$pcdir
bash .github/workflows/test_demo.sh

- name: _xtool build tests
run: |
cd _xtool
llgo build -v ./...

- name: Show test result
run: cat result.md

Expand Down
12 changes: 12 additions & 0 deletions _demo/cppstr/cppstr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"github.com/goplus/lib/c"
"github.com/goplus/lib/cpp/std"
)

func main() {
s := std.Str("Hello world\n")
c.Printf(s.CStr())
print(s.Str(), s.Size(), "\n")
}
7 changes: 7 additions & 0 deletions internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
2 changes: 1 addition & 1 deletion runtime/internal/clite/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
LLGoFiles = "_wrap/debug.c"
LLGoFiles = "$(llvm-config --cflags): _wrap/debug.c"
)

type Info struct {
Expand Down
2 changes: 1 addition & 1 deletion xtool/env/llvm/llvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (e *Env) BinDir() string { return e.binDir }

// Clang returns a new [clang.Cmd] instance.
func (e *Env) Clang() *clang.Cmd {
bin := filepath.Join(e.BinDir(), "clang")
bin := filepath.Join(e.BinDir(), "clang++")
return clang.New(bin)
}

Expand Down
Loading