Browse Source

linux: include musl 'getpagesize' function in release

I wonder why nobody else noticed this bug? In any case, this patch fixes it.
pull/3232/head
Ayke van Laethem 2 years ago
committed by Ron Evans
parent
commit
9de757205f
  1. 1
      Makefile
  2. 4
      builder/builtins.go
  3. 8
      builder/library.go
  4. 4
      builder/mingw-w64.go
  5. 16
      builder/musl.go
  6. 4
      builder/picolibc.go

1
Makefile

@ -786,6 +786,7 @@ endif
@cp -rp lib/musl/src/exit build/release/tinygo/lib/musl/src @cp -rp lib/musl/src/exit build/release/tinygo/lib/musl/src
@cp -rp lib/musl/src/include build/release/tinygo/lib/musl/src @cp -rp lib/musl/src/include build/release/tinygo/lib/musl/src
@cp -rp lib/musl/src/internal build/release/tinygo/lib/musl/src @cp -rp lib/musl/src/internal build/release/tinygo/lib/musl/src
@cp -rp lib/musl/src/legacy build/release/tinygo/lib/musl/src
@cp -rp lib/musl/src/malloc build/release/tinygo/lib/musl/src @cp -rp lib/musl/src/malloc build/release/tinygo/lib/musl/src
@cp -rp lib/musl/src/mman build/release/tinygo/lib/musl/src @cp -rp lib/musl/src/mman build/release/tinygo/lib/musl/src
@cp -rp lib/musl/src/math build/release/tinygo/lib/musl/src @cp -rp lib/musl/src/math build/release/tinygo/lib/musl/src

4
builder/builtins.go

@ -181,11 +181,11 @@ var CompilerRT = Library{
// Development build. // Development build.
return filepath.Join(goenv.Get("TINYGOROOT"), "lib/compiler-rt-builtins") return filepath.Join(goenv.Get("TINYGOROOT"), "lib/compiler-rt-builtins")
}, },
librarySources: func(target string) []string { librarySources: func(target string) ([]string, error) {
builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins
if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") { if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
builtins = append(builtins, aeabiBuiltins...) builtins = append(builtins, aeabiBuiltins...)
} }
return builtins return builtins, nil
}, },
} }

8
builder/library.go

@ -29,7 +29,7 @@ type Library struct {
sourceDir func() string sourceDir func() string
// The source files, relative to sourceDir. // The source files, relative to sourceDir.
librarySources func(target string) []string librarySources func(target string) ([]string, error)
// The source code for the crt1.o file, relative to sourceDir. // The source code for the crt1.o file, relative to sourceDir.
crt1Source string crt1Source string
@ -219,7 +219,11 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ
// Create jobs to compile all sources. These jobs are depended upon by the // Create jobs to compile all sources. These jobs are depended upon by the
// archive job above, so must be run first. // archive job above, so must be run first.
for _, path := range l.librarySources(target) { paths, err := l.librarySources(target)
if err != nil {
return nil, nil, err
}
for _, path := range paths {
// Strip leading "../" parts off the path. // Strip leading "../" parts off the path.
cleanpath := path cleanpath := path
for strings.HasPrefix(cleanpath, "../") { for strings.HasPrefix(cleanpath, "../") {

4
builder/mingw-w64.go

@ -31,9 +31,9 @@ var MinGW = Library{
// No flags necessary because there are no files to compile. // No flags necessary because there are no files to compile.
return nil return nil
}, },
librarySources: func(target string) []string { librarySources: func(target string) ([]string, error) {
// We only use the UCRT DLL file. No source files necessary. // We only use the UCRT DLL file. No source files necessary.
return nil return nil, nil
}, },
} }

16
builder/musl.go

@ -106,7 +106,7 @@ var Musl = Library{
} }
}, },
sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/musl/src") }, sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/musl/src") },
librarySources: func(target string) []string { librarySources: func(target string) ([]string, error) {
arch := compileopts.MuslArchitecture(target) arch := compileopts.MuslArchitecture(target)
globs := []string{ globs := []string{
"env/*.c", "env/*.c",
@ -125,11 +125,14 @@ var Musl = Library{
"stdio/*.c", "stdio/*.c",
"string/*.c", "string/*.c",
"thread/" + arch + "/*.s", "thread/" + arch + "/*.s",
"thread/" + arch + "/*.c",
"thread/*.c", "thread/*.c",
"time/*.c", "time/*.c",
"unistd/*.c", "unistd/*.c",
} }
if arch == "arm" {
// These files need to be added to the start for some reason.
globs = append([]string{"thread/arm/*.c"}, globs...)
}
var sources []string var sources []string
seenSources := map[string]struct{}{} seenSources := map[string]struct{}{}
@ -143,13 +146,16 @@ var Musl = Library{
// > ErrBadPattern, when pattern is malformed. // > ErrBadPattern, when pattern is malformed.
// So the only possible error is when the (statically defined) // So the only possible error is when the (statically defined)
// pattern is wrong. In other words, a programming bug. // pattern is wrong. In other words, a programming bug.
panic("could not glob source dirs: " + err.Error()) return nil, fmt.Errorf("musl: could not glob source dirs: %w", err)
}
if len(matches) == 0 {
return nil, fmt.Errorf("musl: did not find any files for pattern %#v", pattern)
} }
for _, match := range matches { for _, match := range matches {
relpath, err := filepath.Rel(basepath, match) relpath, err := filepath.Rel(basepath, match)
if err != nil { if err != nil {
// Not sure if this is even possible. // Not sure if this is even possible.
panic(err) return nil, err
} }
// Make sure architecture specific files override generic files. // Make sure architecture specific files override generic files.
id := strings.ReplaceAll(relpath, "/"+arch+"/", "/") id := strings.ReplaceAll(relpath, "/"+arch+"/", "/")
@ -161,7 +167,7 @@ var Musl = Library{
sources = append(sources, relpath) sources = append(sources, relpath)
} }
} }
return sources return sources, nil
}, },
crt1Source: "../crt/crt1.c", // lib/musl/crt/crt1.c crt1Source: "../crt/crt1.c", // lib/musl/crt/crt1.c
} }

4
builder/picolibc.go

@ -38,8 +38,8 @@ var Picolibc = Library{
} }
}, },
sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/picolibc/newlib") }, sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/picolibc/newlib") },
librarySources: func(target string) []string { librarySources: func(target string) ([]string, error) {
return picolibcSources return picolibcSources, nil
}, },
} }

Loading…
Cancel
Save