mirror of
https://github.com/danog/gllvm.git
synced 2024-11-26 19:24:40 +01:00
Various fixes, including one for the dead_strip issue. Issue #22.
This commit is contained in:
parent
339814df28
commit
08903954e1
@ -1,9 +1,8 @@
|
|||||||
|
|
||||||
|
all: test
|
||||||
|
|
||||||
|
#one:
|
||||||
|
# ${CC} test.c -dead_strip -fsanitize=address -o test
|
||||||
one:
|
|
||||||
${CC} test.c -fsanitize=address -o test
|
|
||||||
|
|
||||||
|
|
||||||
test.o:
|
test.o:
|
||||||
@ -11,10 +10,9 @@ test.o:
|
|||||||
|
|
||||||
|
|
||||||
test: test.o
|
test: test.o
|
||||||
${CC} test.o -fsanitize=address -o test
|
${CC} test.o -dead_strip -fsanitize=address -o test
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f test.o test .test* *~
|
rm -f test.o test .test* *~
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
### Copy vmlinux into the bootable linux folder and install the new kernel
|
### Copy vmlinux into the bootable linux folder and install the new kernel
|
||||||
cp $HOME/standalone-build/vmlinux $HOME/bootable-linux/
|
cp $HOME/standalone-build/vmlinux $HOME/linux-stable/
|
||||||
|
|
||||||
cd $HOME/bootable-linux
|
cd $HOME/linux-stable
|
||||||
|
|
||||||
scripts/sortextable vmlinux
|
scripts/sortextable vmlinux
|
||||||
nm -n vmlinux | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > System.map
|
nm -n vmlinux | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > System.map
|
||||||
make CC=clang HOSTCC=clang
|
make CC=gclang HOSTCC=gclang
|
||||||
sudo make modules_install install
|
sudo make modules_install install
|
||||||
|
@ -211,6 +211,8 @@ func compileTimeLinkFiles(compilerExecName string, pr parserResult, objFiles []s
|
|||||||
LogError("%v %v failed to link: %v.", compilerExecName, args, err)
|
LogError("%v %v failed to link: %v.", compilerExecName, args, err)
|
||||||
//was LogFatal
|
//was LogFatal
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
LogInfo("LINKING: %v %v", compilerExecName, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +243,30 @@ func buildBitcodeFile(compilerExecName string, pr parserResult, srcFile string,
|
|||||||
// Tries to build object file
|
// Tries to build object file
|
||||||
func execCompile(compilerExecName string, pr parserResult, wg *sync.WaitGroup, ok *bool) {
|
func execCompile(compilerExecName string, pr parserResult, wg *sync.WaitGroup, ok *bool) {
|
||||||
defer (*wg).Done()
|
defer (*wg).Done()
|
||||||
success, err := execCmd(compilerExecName, pr.InputList, "")
|
//iam: strickly speaking we should do more work here depending on whether this is
|
||||||
|
// a compile only, a link only, or ...
|
||||||
|
// But for the now, we just remove forbidden arguments
|
||||||
|
var success bool
|
||||||
|
var err error
|
||||||
|
if len(pr.ForbiddenFlags) > 0 {
|
||||||
|
filteredArgs := pr.InputList[:0]
|
||||||
|
for _, arg := range pr.InputList {
|
||||||
|
found := false
|
||||||
|
for _, bad := range pr.ForbiddenFlags {
|
||||||
|
if bad == arg {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
filteredArgs = append(filteredArgs, arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
success, err = execCmd(compilerExecName, filteredArgs, "")
|
||||||
|
} else {
|
||||||
|
success, err = execCmd(compilerExecName, pr.InputList, "")
|
||||||
|
}
|
||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
LogError("Failed to compile using given arguments:\n%v %v\nexit status: %v\n", compilerExecName, pr.InputList, err)
|
LogError("Failed to compile using given arguments:\n%v %v\nexit status: %v\n", compilerExecName, pr.InputList, err)
|
||||||
*ok = false
|
*ok = false
|
||||||
|
@ -43,10 +43,11 @@ package shared
|
|||||||
// May 2 2018 handleArchives rewritten to handle multiple occurrences of files with the same name.
|
// May 2 2018 handleArchives rewritten to handle multiple occurrences of files with the same name.
|
||||||
// corresponds with wllvm 1.2.0. Gonna try and keep them in synch.
|
// corresponds with wllvm 1.2.0. Gonna try and keep them in synch.
|
||||||
// 1.2.1 May 13th 2018 -fsanitize= needs to be compile AND link.
|
// 1.2.1 May 13th 2018 -fsanitize= needs to be compile AND link.
|
||||||
|
// 1.2.2 May 24th 2018 Fix extracting from archives on darwin, plus travis build for both linux and darwin.
|
||||||
|
|
||||||
//
|
//
|
||||||
const gllvmVersion = "1.2.1"
|
const gllvmVersion = "1.2.2"
|
||||||
const gllvmReleaseDate = "May 23 2018"
|
const gllvmReleaseDate = "May 24 2018"
|
||||||
|
|
||||||
const osDARWIN = "darwin"
|
const osDARWIN = "darwin"
|
||||||
const osLINUX = "linux"
|
const osLINUX = "linux"
|
||||||
|
@ -324,7 +324,7 @@ func listArchiveFiles(inputFile string) (contents []string) {
|
|||||||
|
|
||||||
func extractFile(archive string, filename string, instance int) bool {
|
func extractFile(archive string, filename string, instance int) bool {
|
||||||
var arArgs []string
|
var arArgs []string
|
||||||
if runtime.GOOS != osDARWIN {
|
if runtime.GOOS != osDARWIN {
|
||||||
arArgs = append(arArgs, "xN")
|
arArgs = append(arArgs, "xN")
|
||||||
arArgs = append(arArgs, strconv.Itoa(instance))
|
arArgs = append(arArgs, strconv.Itoa(instance))
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,7 +40,6 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,6 +50,7 @@ type parserResult struct {
|
|||||||
OutputFilename string
|
OutputFilename string
|
||||||
CompileArgs []string
|
CompileArgs []string
|
||||||
LinkArgs []string
|
LinkArgs []string
|
||||||
|
ForbiddenFlags []string
|
||||||
IsVerbose bool
|
IsVerbose bool
|
||||||
IsDependencyOnly bool
|
IsDependencyOnly bool
|
||||||
IsPreprocessOnly bool
|
IsPreprocessOnly bool
|
||||||
@ -219,10 +219,10 @@ func parse(argList []string) parserResult {
|
|||||||
"-Xassembler": {1, pr.defaultBinaryCallback},
|
"-Xassembler": {1, pr.defaultBinaryCallback},
|
||||||
"-Xlinker": {1, pr.defaultBinaryCallback},
|
"-Xlinker": {1, pr.defaultBinaryCallback},
|
||||||
|
|
||||||
"-l": {1, pr.linkBinaryCallback},
|
"-l": {1, pr.linkBinaryCallback},
|
||||||
"-L": {1, pr.linkBinaryCallback},
|
"-L": {1, pr.linkBinaryCallback},
|
||||||
"-T": {1, pr.linkBinaryCallback},
|
"-T": {1, pr.linkBinaryCallback},
|
||||||
"-u": {1, pr.linkBinaryCallback},
|
"-u": {1, pr.linkBinaryCallback},
|
||||||
"-install_name": {1, pr.linkBinaryCallback},
|
"-install_name": {1, pr.linkBinaryCallback},
|
||||||
|
|
||||||
"-e": {1, pr.linkBinaryCallback},
|
"-e": {1, pr.linkBinaryCallback},
|
||||||
@ -248,7 +248,8 @@ func parse(argList []string) parserResult {
|
|||||||
"-coverage": {0, pr.compileLinkUnaryCallback},
|
"-coverage": {0, pr.compileLinkUnaryCallback},
|
||||||
"--coverage": {0, pr.compileLinkUnaryCallback},
|
"--coverage": {0, pr.compileLinkUnaryCallback},
|
||||||
|
|
||||||
"-Wl,-dead_strip": {0, pr.darwinWarningLinkUnaryCallback},
|
"-Wl,-dead_strip": {0, pr.warningLinkUnaryCallback},
|
||||||
|
"-dead_strip": {0, pr.warningLinkUnaryCallback}, //iam: tor does this. We lose the bitcode :-(
|
||||||
}
|
}
|
||||||
|
|
||||||
var argPatterns = map[string]flagInfo{
|
var argPatterns = map[string]flagInfo{
|
||||||
@ -263,25 +264,27 @@ func parse(argList []string) parserResult {
|
|||||||
`^-B.+$`: {0, pr.compileLinkUnaryCallback},
|
`^-B.+$`: {0, pr.compileLinkUnaryCallback},
|
||||||
`^-isystem.+$`: {0, pr.compileLinkUnaryCallback},
|
`^-isystem.+$`: {0, pr.compileLinkUnaryCallback},
|
||||||
`^-U.+$`: {0, pr.compileUnaryCallback},
|
`^-U.+$`: {0, pr.compileUnaryCallback},
|
||||||
`^-Wl,.+$`: {0, pr.linkUnaryCallback},
|
//iam: need to be careful here, not mix up linker and warning flags.
|
||||||
`^-W[^l].*$`: {0, pr.compileUnaryCallback},
|
`^-Wl,.+$`: {0, pr.linkUnaryCallback},
|
||||||
`^-fsanitize=.+$`: {0, pr.compileLinkUnaryCallback},
|
`^-W[^l].*$`: {0, pr.compileUnaryCallback},
|
||||||
`^-f.+$`: {0, pr.compileUnaryCallback},
|
`^-W[l][^,].*$`: {0, pr.compileUnaryCallback}, //iam: tor has a few -Wl...
|
||||||
`^-rtlib=.+$`: {0, pr.linkUnaryCallback},
|
`^-fsanitize=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||||
`^-std=.+$`: {0, pr.compileUnaryCallback},
|
`^-f.+$`: {0, pr.compileUnaryCallback},
|
||||||
`^-stdlib=.+$`: {0, pr.compileLinkUnaryCallback},
|
`^-rtlib=.+$`: {0, pr.linkUnaryCallback},
|
||||||
`^-mtune=.+$`: {0, pr.compileUnaryCallback},
|
`^-std=.+$`: {0, pr.compileUnaryCallback},
|
||||||
`^--sysroot=.+$`: {0, pr.compileUnaryCallback},
|
`^-stdlib=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||||
`^-print-prog-name=.*$`: {0, pr.compileUnaryCallback},
|
`^-mtune=.+$`: {0, pr.compileUnaryCallback},
|
||||||
`^-print-file-name=.*$`: {0, pr.compileUnaryCallback},
|
`^--sysroot=.+$`: {0, pr.compileUnaryCallback},
|
||||||
`^-mmacosx-version-min=.+$`: {0, pr.compileLinkUnaryCallback},
|
`^-print-prog-name=.*$`: {0, pr.compileUnaryCallback},
|
||||||
`^-mstack-alignment=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
`^-print-file-name=.*$`: {0, pr.compileUnaryCallback},
|
||||||
`^-march=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
`^-mmacosx-version-min=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||||
`^-mregparm=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
`^-mstack-alignment=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||||
`^-mcmodel=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
`^-march=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||||
`^-mpreferred-stack-boundary=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
`^-mregparm=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||||
`^-mindirect-branch=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
`^-mcmodel=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||||
`^--param=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
`^-mpreferred-stack-boundary=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||||
|
`^-mindirect-branch=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||||
|
`^--param=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,12 +409,9 @@ func (pr *parserResult) compileUnaryCallback(flag string, _ []string) {
|
|||||||
pr.CompileArgs = append(pr.CompileArgs, flag)
|
pr.CompileArgs = append(pr.CompileArgs, flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *parserResult) darwinWarningLinkUnaryCallback(flag string, _ []string) {
|
func (pr *parserResult) warningLinkUnaryCallback(flag string, _ []string) {
|
||||||
if runtime.GOOS == osDARWIN {
|
LogWarning("The flag %v cannot be used with this tool, we ignore it, else we lose the bitcode section.\n", flag)
|
||||||
fmt.Println("The flag", flag, "cannot be used with this tool.")
|
pr.ForbiddenFlags = append(pr.ForbiddenFlags, flag)
|
||||||
} else {
|
|
||||||
pr.LinkArgs = append(pr.LinkArgs, flag)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *parserResult) defaultBinaryCallback(_ string, _ []string) {
|
func (pr *parserResult) defaultBinaryCallback(_ string, _ []string) {
|
||||||
|
@ -51,7 +51,7 @@ func execCmd(cmdExecName string, args []string, workingDir string) (success bool
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ecode = 1
|
ecode = 1
|
||||||
}
|
}
|
||||||
LogDebug("execCmd: %v %v in %v had exitCode %v\n", cmdExecName, args, workingDir, ecode)
|
LogDebug("execCmd: %v %v had exitCode %v\n", cmdExecName, args, ecode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogDebug("execCmd: error was %v\n", err)
|
LogDebug("execCmd: error was %v\n", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user