mirror of
https://github.com/danog/gllvm.git
synced 2024-11-30 04:59:04 +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 -fsanitize=address -o test
|
||||
#one:
|
||||
# ${CC} test.c -dead_strip -fsanitize=address -o test
|
||||
|
||||
|
||||
test.o:
|
||||
@ -11,10 +10,9 @@ test.o:
|
||||
|
||||
|
||||
test: test.o
|
||||
${CC} test.o -fsanitize=address -o test
|
||||
${CC} test.o -dead_strip -fsanitize=address -o test
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
rm -f test.o test .test* *~
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
### 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
|
||||
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
|
||||
|
@ -211,6 +211,8 @@ func compileTimeLinkFiles(compilerExecName string, pr parserResult, objFiles []s
|
||||
LogError("%v %v failed to link: %v.", compilerExecName, args, err)
|
||||
//was LogFatal
|
||||
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
|
||||
func execCompile(compilerExecName string, pr parserResult, wg *sync.WaitGroup, ok *bool) {
|
||||
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 {
|
||||
LogError("Failed to compile using given arguments:\n%v %v\nexit status: %v\n", compilerExecName, pr.InputList, err)
|
||||
*ok = false
|
||||
|
@ -43,10 +43,11 @@ package shared
|
||||
// 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.
|
||||
// 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 gllvmReleaseDate = "May 23 2018"
|
||||
const gllvmVersion = "1.2.2"
|
||||
const gllvmReleaseDate = "May 24 2018"
|
||||
|
||||
const osDARWIN = "darwin"
|
||||
const osLINUX = "linux"
|
||||
|
@ -324,7 +324,7 @@ func listArchiveFiles(inputFile string) (contents []string) {
|
||||
|
||||
func extractFile(archive string, filename string, instance int) bool {
|
||||
var arArgs []string
|
||||
if runtime.GOOS != osDARWIN {
|
||||
if runtime.GOOS != osDARWIN {
|
||||
arArgs = append(arArgs, "xN")
|
||||
arArgs = append(arArgs, strconv.Itoa(instance))
|
||||
} else {
|
||||
|
@ -40,7 +40,6 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -51,6 +50,7 @@ type parserResult struct {
|
||||
OutputFilename string
|
||||
CompileArgs []string
|
||||
LinkArgs []string
|
||||
ForbiddenFlags []string
|
||||
IsVerbose bool
|
||||
IsDependencyOnly bool
|
||||
IsPreprocessOnly bool
|
||||
@ -219,10 +219,10 @@ func parse(argList []string) parserResult {
|
||||
"-Xassembler": {1, pr.defaultBinaryCallback},
|
||||
"-Xlinker": {1, pr.defaultBinaryCallback},
|
||||
|
||||
"-l": {1, pr.linkBinaryCallback},
|
||||
"-L": {1, pr.linkBinaryCallback},
|
||||
"-T": {1, pr.linkBinaryCallback},
|
||||
"-u": {1, pr.linkBinaryCallback},
|
||||
"-l": {1, pr.linkBinaryCallback},
|
||||
"-L": {1, pr.linkBinaryCallback},
|
||||
"-T": {1, pr.linkBinaryCallback},
|
||||
"-u": {1, pr.linkBinaryCallback},
|
||||
"-install_name": {1, pr.linkBinaryCallback},
|
||||
|
||||
"-e": {1, pr.linkBinaryCallback},
|
||||
@ -248,7 +248,8 @@ func parse(argList []string) parserResult {
|
||||
"-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{
|
||||
@ -263,25 +264,27 @@ func parse(argList []string) parserResult {
|
||||
`^-B.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-isystem.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-U.+$`: {0, pr.compileUnaryCallback},
|
||||
`^-Wl,.+$`: {0, pr.linkUnaryCallback},
|
||||
`^-W[^l].*$`: {0, pr.compileUnaryCallback},
|
||||
`^-fsanitize=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-f.+$`: {0, pr.compileUnaryCallback},
|
||||
`^-rtlib=.+$`: {0, pr.linkUnaryCallback},
|
||||
`^-std=.+$`: {0, pr.compileUnaryCallback},
|
||||
`^-stdlib=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-mtune=.+$`: {0, pr.compileUnaryCallback},
|
||||
`^--sysroot=.+$`: {0, pr.compileUnaryCallback},
|
||||
`^-print-prog-name=.*$`: {0, pr.compileUnaryCallback},
|
||||
`^-print-file-name=.*$`: {0, pr.compileUnaryCallback},
|
||||
`^-mmacosx-version-min=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-mstack-alignment=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||
`^-march=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||
`^-mregparm=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||
`^-mcmodel=.+$`: {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
|
||||
//iam: need to be careful here, not mix up linker and warning flags.
|
||||
`^-Wl,.+$`: {0, pr.linkUnaryCallback},
|
||||
`^-W[^l].*$`: {0, pr.compileUnaryCallback},
|
||||
`^-W[l][^,].*$`: {0, pr.compileUnaryCallback}, //iam: tor has a few -Wl...
|
||||
`^-fsanitize=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-f.+$`: {0, pr.compileUnaryCallback},
|
||||
`^-rtlib=.+$`: {0, pr.linkUnaryCallback},
|
||||
`^-std=.+$`: {0, pr.compileUnaryCallback},
|
||||
`^-stdlib=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-mtune=.+$`: {0, pr.compileUnaryCallback},
|
||||
`^--sysroot=.+$`: {0, pr.compileUnaryCallback},
|
||||
`^-print-prog-name=.*$`: {0, pr.compileUnaryCallback},
|
||||
`^-print-file-name=.*$`: {0, pr.compileUnaryCallback},
|
||||
`^-mmacosx-version-min=.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-mstack-alignment=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||
`^-march=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||
`^-mregparm=.+$`: {0, pr.compileUnaryCallback}, //iam: linux kernel stuff
|
||||
`^-mcmodel=.+$`: {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)
|
||||
}
|
||||
|
||||
func (pr *parserResult) darwinWarningLinkUnaryCallback(flag string, _ []string) {
|
||||
if runtime.GOOS == osDARWIN {
|
||||
fmt.Println("The flag", flag, "cannot be used with this tool.")
|
||||
} else {
|
||||
pr.LinkArgs = append(pr.LinkArgs, flag)
|
||||
}
|
||||
func (pr *parserResult) warningLinkUnaryCallback(flag string, _ []string) {
|
||||
LogWarning("The flag %v cannot be used with this tool, we ignore it, else we lose the bitcode section.\n", flag)
|
||||
pr.ForbiddenFlags = append(pr.ForbiddenFlags, flag)
|
||||
}
|
||||
|
||||
func (pr *parserResult) defaultBinaryCallback(_ string, _ []string) {
|
||||
|
@ -51,7 +51,7 @@ func execCmd(cmdExecName string, args []string, workingDir string) (success bool
|
||||
if err != nil {
|
||||
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 {
|
||||
LogDebug("execCmd: error was %v\n", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user