mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-22 05:19:03 +00:00
builder: simplify bdwgc libc dependency
Header files are built immediately, not in a separate job, so no dependency is needed here. All we need is a flag whether to add flags for that given libc.
This commit is contained in:
committed by
Ron Evans
parent
8486e07377
commit
4c54aa20da
@@ -49,6 +49,7 @@ var BoehmGC = Library{
|
|||||||
"-I" + libdir + "/include",
|
"-I" + libdir + "/include",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
needsLibc: true,
|
||||||
sourceDir: func() string {
|
sourceDir: func() string {
|
||||||
return filepath.Join(goenv.Get("TINYGOROOT"), "lib/bdwgc")
|
return filepath.Join(goenv.Get("TINYGOROOT"), "lib/bdwgc")
|
||||||
},
|
},
|
||||||
|
|||||||
+7
-12
@@ -147,14 +147,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
// the libc needs them.
|
// the libc needs them.
|
||||||
root := goenv.Get("TINYGOROOT")
|
root := goenv.Get("TINYGOROOT")
|
||||||
var libcDependencies []*compileJob
|
var libcDependencies []*compileJob
|
||||||
var libcJob *compileJob
|
|
||||||
switch config.Target.Libc {
|
switch config.Target.Libc {
|
||||||
case "darwin-libSystem":
|
case "darwin-libSystem":
|
||||||
libcJob = makeDarwinLibSystemJob(config, tmpdir)
|
libcJob := makeDarwinLibSystemJob(config, tmpdir)
|
||||||
libcDependencies = append(libcDependencies, libcJob)
|
libcDependencies = append(libcDependencies, libcJob)
|
||||||
case "musl":
|
case "musl":
|
||||||
var unlock func()
|
var unlock func()
|
||||||
libcJob, unlock, err = libMusl.load(config, tmpdir, nil)
|
libcJob, unlock, err := libMusl.load(config, tmpdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BuildResult{}, err
|
return BuildResult{}, err
|
||||||
}
|
}
|
||||||
@@ -162,7 +161,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
libcDependencies = append(libcDependencies, dummyCompileJob(filepath.Join(filepath.Dir(libcJob.result), "crt1.o")))
|
libcDependencies = append(libcDependencies, dummyCompileJob(filepath.Join(filepath.Dir(libcJob.result), "crt1.o")))
|
||||||
libcDependencies = append(libcDependencies, libcJob)
|
libcDependencies = append(libcDependencies, libcJob)
|
||||||
case "picolibc":
|
case "picolibc":
|
||||||
libcJob, unlock, err := libPicolibc.load(config, tmpdir, nil)
|
libcJob, unlock, err := libPicolibc.load(config, tmpdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BuildResult{}, err
|
return BuildResult{}, err
|
||||||
}
|
}
|
||||||
@@ -175,15 +174,14 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
}
|
}
|
||||||
libcDependencies = append(libcDependencies, dummyCompileJob(path))
|
libcDependencies = append(libcDependencies, dummyCompileJob(path))
|
||||||
case "wasmbuiltins":
|
case "wasmbuiltins":
|
||||||
libcJob, unlock, err := libWasmBuiltins.load(config, tmpdir, nil)
|
libcJob, unlock, err := libWasmBuiltins.load(config, tmpdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BuildResult{}, err
|
return BuildResult{}, err
|
||||||
}
|
}
|
||||||
defer unlock()
|
defer unlock()
|
||||||
libcDependencies = append(libcDependencies, libcJob)
|
libcDependencies = append(libcDependencies, libcJob)
|
||||||
case "mingw-w64":
|
case "mingw-w64":
|
||||||
var unlock func()
|
libcJob, unlock, err := libMinGW.load(config, tmpdir)
|
||||||
libcJob, unlock, err = libMinGW.load(config, tmpdir, nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BuildResult{}, err
|
return BuildResult{}, err
|
||||||
}
|
}
|
||||||
@@ -704,7 +702,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
// Add compiler-rt dependency if needed. Usually this is a simple load from
|
// Add compiler-rt dependency if needed. Usually this is a simple load from
|
||||||
// a cache.
|
// a cache.
|
||||||
if config.Target.RTLib == "compiler-rt" {
|
if config.Target.RTLib == "compiler-rt" {
|
||||||
job, unlock, err := libCompilerRT.load(config, tmpdir, nil)
|
job, unlock, err := libCompilerRT.load(config, tmpdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -714,10 +712,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
|
|
||||||
// The Boehm collector is stored in a separate C library.
|
// The Boehm collector is stored in a separate C library.
|
||||||
if config.GC() == "boehm" {
|
if config.GC() == "boehm" {
|
||||||
if libcJob == nil {
|
job, unlock, err := BoehmGC.load(config, tmpdir)
|
||||||
return BuildResult{}, fmt.Errorf("boehm GC isn't supported with libc %s", config.Target.Libc)
|
|
||||||
}
|
|
||||||
job, unlock, err := BoehmGC.load(config, tmpdir, libcJob)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BuildResult{}, err
|
return BuildResult{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-12
@@ -25,6 +25,9 @@ type Library struct {
|
|||||||
// cflags returns the C flags specific to this library
|
// cflags returns the C flags specific to this library
|
||||||
cflags func(target, headerPath string) []string
|
cflags func(target, headerPath string) []string
|
||||||
|
|
||||||
|
// needsLibc is set to true if this library needs libc headers.
|
||||||
|
needsLibc bool
|
||||||
|
|
||||||
// The source directory.
|
// The source directory.
|
||||||
sourceDir func() string
|
sourceDir func() string
|
||||||
|
|
||||||
@@ -43,11 +46,7 @@ type Library struct {
|
|||||||
// output archive file, it is expected to be removed after use.
|
// output archive file, it is expected to be removed after use.
|
||||||
// As a side effect, this call creates the library header files if they didn't
|
// As a side effect, this call creates the library header files if they didn't
|
||||||
// exist yet.
|
// exist yet.
|
||||||
// The provided libc job (if not null) will cause this libc to be added as a
|
func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJob, abortLock func(), err error) {
|
||||||
// dependency for all C compiler jobs, and adds libc headers for the given
|
|
||||||
// target config. In other words, pass this libc if the library needs a libc to
|
|
||||||
// compile.
|
|
||||||
func (l *Library) load(config *compileopts.Config, tmpdir string, libc *compileJob) (job *compileJob, abortLock func(), err error) {
|
|
||||||
outdir := config.LibcPath(l.name)
|
outdir := config.LibcPath(l.name)
|
||||||
archiveFilePath := filepath.Join(outdir, "lib.a")
|
archiveFilePath := filepath.Join(outdir, "lib.a")
|
||||||
|
|
||||||
@@ -180,7 +179,7 @@ func (l *Library) load(config *compileopts.Config, tmpdir string, libc *compileJ
|
|||||||
args = append(args, "-mfpu=vfpv2")
|
args = append(args, "-mfpu=vfpv2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if libc != nil {
|
if l.needsLibc {
|
||||||
args = append(args, config.LibcCFlags()...)
|
args = append(args, config.LibcCFlags()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,9 +250,6 @@ func (l *Library) load(config *compileopts.Config, tmpdir string, libc *compileJ
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if libc != nil {
|
|
||||||
objfile.dependencies = append(objfile.dependencies, libc)
|
|
||||||
}
|
|
||||||
job.dependencies = append(job.dependencies, objfile)
|
job.dependencies = append(job.dependencies, objfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,9 +280,6 @@ func (l *Library) load(config *compileopts.Config, tmpdir string, libc *compileJ
|
|||||||
return os.Rename(tmpfile.Name(), filepath.Join(outdir, "crt1.o"))
|
return os.Rename(tmpfile.Name(), filepath.Join(outdir, "crt1.o"))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if libc != nil {
|
|
||||||
crt1Job.dependencies = append(crt1Job.dependencies, libc)
|
|
||||||
}
|
|
||||||
job.dependencies = append(job.dependencies, crt1Job)
|
job.dependencies = append(job.dependencies, crt1Job)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user