-trimpath records TinyGo C source paths as cache paths
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- build-system
Línea de trabajo
Empieza en builder, en Config.CFlags, e inspecciona cómo crea los mapas de prefijos de TINYGOROOT y GOCACHE; la reproducción proporcionada identifica el solapamiento de prefijos de caché. Añade la prueba del issue como builder/trimpath_test.go y luego ejecuta TINYGOROOT="$PWD" go test -tags llvm23 ./builder -run '^TestTrimPathCFlagsMapTinyGoSource$' -count=1 -v. El trabajo estará listo cuando pasen ambos casos y DWARF registre la ruta esperada del código fuente de TinyGo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
When GOCACHE is /tmp/tinygo and TINYGOROOT is the sibling directory /tmp/tinygo-source, the cache prefix map also matches C files under TINYGOROOT. Clang uses the later cache map and records /tmp/tinygo-source/probe.c as /_/tinygo-cache-source/probe.c in DWARF. The expected path is /_/github.com/tinygo-org/tinygo/probe.c.
Reproduction
Add this test as builder/trimpath_test.go. It compiles a C file with the flags from Config.CFlags and reads the DWARF compile-unit path from the ELF object. The separate-directory case passes, but the cache-prefix case fails.
package builder
import (
"debug/dwarf"
"debug/elf"
"os"
"path/filepath"
"testing"
"github.com/tinygo-org/tinygo/compileopts"
"github.com/tinygo-org/tinygo/goenv"
)
func TestTrimPathCFlagsMapTinyGoSource(t *testing.T) {
for _, tc := range []struct {
name string
overlap bool
}{
{name: "separate"},
{name: "cache-prefix", overlap: true},
} {
t.Run(tc.name, func(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("XDG_CACHE_HOME", home)
t.Setenv("LocalAppData", home)
cache := goenv.Get("GOCACHE")
tinygoRoot := filepath.Join(filepath.Dir(cache), "source")
if tc.overlap {
tinygoRoot = cache + "-source"
}
for _, name := range []string{
"src/runtime/internal/sys/zversion.go",
"src/device/arm/arm.go",
} {
filename := filepath.Join(tinygoRoot, filepath.FromSlash(name))
if err := os.MkdirAll(filepath.Dir(filename), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filename, nil, 0o644); err != nil {
t.Fatal(err)
}
}
t.Setenv("TINYGOROOT", tinygoRoot)
source := filepath.Join(tinygoRoot, "probe.c")
if err := os.WriteFile(source, []byte("int probe(void) { return 1; }\n"), 0o644); err != nil {
t.Fatal(err)
}
config := &compileopts.Config{
Options: &compileopts.Options{TrimPath: true, Opt: "0"},
Target: &compileopts.TargetSpec{
Triple: "x86_64-unknown-linux-gnu", GOOS: "linux", GOARCH: "amd64",
},
}
objectPath := filepath.Join(home, "probe.o")
flags := append([]string{"-c", "-o", objectPath, source}, config.CFlags(false)...)
if err := runCCompiler(flags...); err != nil {
t.Fatal(err)
}
object, err := elf.Open(objectPath)
if err != nil {
t.Fatal(err)
}
defer object.Close()
debugInfo, err := object.DWARF()
if err != nil {
t.Fatal(err)
}
unit, err := debugInfo.Reader().Next()
if err != nil {
t.Fatal(err)
}
if unit == nil || unit.Tag != dwarf.TagCompileUnit {
t.Fatalf("expected a DWARF compile unit, got %v", unit)
}
want := config.CSourcePath("github.com/tinygo-org/tinygo/probe.c")
if got := unit.Val(dwarf.AttrName); got != want {
t.Errorf("DWARF source path = %q, want %q", got, want)
}
})
}
}
On macOS/arm64 with Homebrew Clang 23.1.4:
TINYGOROOT="$PWD" go test -tags llvm23 ./builder -run '^TestTrimPathCFlagsMapTinyGoSource$' -count=1 -v
--- PASS: TestTrimPathCFlagsMapTinyGoSource/separate
--- FAIL: TestTrimPathCFlagsMapTinyGoSource/cache-prefix
DWARF source path = "/_/tinygo-cache-source/probe.c", want "/_/github.com/tinygo-org/tinygo/probe.c"
This tests the TINYGOROOT and GOCACHE maps in Config.CFlags. PR #6155 covers the package module map.
- Lenguaje dominante
- Go
- Estrellas
- 17.8k
- Forks
- 1.1k
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 380
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de tinygo-org/tinygo
-
avr: SPI Mode2 runs as mode 1Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
tinygo-org/tinygo#6727 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
tinygo-org/tinygo#6711 ·
Los mantenedores suelen responder en 1 día
-
Builds are not reproducible: cgo snippet paths in debug infoPosiblemente ocupada @tridev-tej la tomó hace 1 día. Abiertoenhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
tinygo-org/tinygo#6619 ·
Los mantenedores suelen responder en 1 día
-
Fix the targets that tinygo build -target rejectsPosiblemente ocupada @narguis la tomó hace 2 días. Abiertobug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
tinygo-org/tinygo#6617 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
tinygo-org/tinygo#6312 ·
Los mantenedores suelen responder en 1 día
Todos los issues de tinygo-org/tinygo
Issues similares
-
release
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
github/gh-aw-mcpg#17603 ·
Los mantenedores suelen responder en 1 día
-
help wanted
Dificultad 1/5 Menos de una hora Aptitud para principiantes 94/100
oras-project/oras-go#1827 ·
Los mantenedores suelen responder en 1 día
-
docs: database/sql Sessions example never commits its batch, and its "Full Example" link is a 404Abiertodocumentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
ClickHouse/clickhouse-go#2185 ·
Los mantenedores suelen responder en 1 día
-
bug needs triage receiver/podman
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
open-telemetry/opentelemetry-collector-contrib#53700 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
tagvalue.Read fails with "token too long" on lines over 64 KiBPosiblemente ocupada @G26karthik la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
spdx/tools-golang#319 ·