mirror of
https://github.com/danog/gllvm.git
synced 2024-11-26 19:34:49 +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"
|
||||
|
@ -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
|
||||
@ -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,8 +264,10 @@ func parse(argList []string) parserResult {
|
||||
`^-B.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-isystem.+$`: {0, pr.compileLinkUnaryCallback},
|
||||
`^-U.+$`: {0, pr.compileUnaryCallback},
|
||||
//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},
|
||||
@ -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