Hello,

It looks as though you may not be taking into account the caching done by
the "go" command. The go "build" command caches compile/build results and
will copy things out of the cache if it can establish that the source in
question hasn't changed. In your transcript that's probably what the line

cp
/root/.cache/go-build/11/11b27c148a103033dee37422bbbe76ca68d1cc97f79c6557c0909f358bdd2a5c-d
$WORK/b001/_pkg1_.a

is doing. Here is another example:

$ go build -x himom.go 1> first.txt 2>&1
$ fgrep himom.go first.txt
<installpath>/bin/llvm-goc -c -g -m64 <flags> ... -o $WORK/b001/_go_.o -I
$WORK/b001/_importcfgroot_ ./himom.go
$ rm himom
$ go build -x himom.go 1> second.txt 2>&
$ fgrep himom.go second.txt
$

In the second build the linker will run but the compiled "himom.go" code
will be drawn from the cache.

For doing test compiles (where you want to force the compiler to run) try
execting "go clean -cache" beforehand. That will remove the entire build
cache.

Thanks, Than


On Tue, Dec 25, 2018 at 4:05 PM Benedikt T <[email protected]> wrote:

> Hi!
>
> I'm currently trying to retrieve the LLVM IR from the compilation process.
> To do so, I followed the given instructions. From my perspective I'm not
> missing anything, but I can't get llvm-goc to emit the llvm IR.
> I created a transcript and added parameters to the the original call to
> llvm-goc. Here is my fully modified script:
>
> root@llvmbuilder-successful-s-1vcpu-2gb-fra1-01-s-1vcpu-2gb-fra1-01:~/compile/poc#
> cat ./poc_transcript.sh
> rm -r /tmp/go-build598282723
> WORK=/tmp/go-build598282723
> mkdir -p $WORK/b001/
> cat >$WORK/b001/importcfg.link << 'EOF' # internal
> packagefile
> _/root/compile/poc=/root/.cache/go-build/11/11b27c148a103033dee37422bbbe76ca68d1cc97f79c6557c0909f358bdd2a5c-d
> EOF
> mkdir -p $WORK/b001/exe/
> cp
> /root/.cache/go-build/11/11b27c148a103033dee37422bbbe76ca68d1cc97f79c6557c0909f358bdd2a5c-d
> $WORK/b001/_pkg1_.a
> cd $WORK/b001/
> ar x ./_pkg1_.a _cgo_flags
> cd .
> ar d $WORK/b001/_pkg1_.a _cgo_flags
> #/root/llvm-install/bin/llvm-goc -v -o $WORK/b001/exe/a.out "-Wl,-(" -m64
> -Wl,--whole-archive $WORK/b001/_pkg1_.a -Wl,--no-whole-archive "-Wl,-)"
> -Wl,--build-id=0x6b69526757524436506941386641384b70444b5f2f66754b585f536a45384b497a713930744a77304e2f54337764784d68356d3164537756767a5f4569542f6b69526757524436506941386641384b70444b5f
> -Wl,-E -static-libgo/root/llvm-install/bin/llvm-goc -o
> /root/compile/poc/poc.llvm -S -emit-llvm "-Wl,-(" -m64 -Wl,--whole-archive
> $WORK/b001/_pkg1_.a -Wl,--no-whole-archive "-Wl,-)"
> -Wl,--build-id=0x6b69526757524436506941386641384b70444b5f2f66754b585f536a45384b497a713930744a77304e2f54337764784d68356d3164537756767a5f4569542f6b69526757524436506941386641384b70444b5f
> -Wl,-E -static-libgo
> #/root/llvm-install/tools/buildid -w $WORK/b001/exe/a.out # internal
> #mv $WORK/b001/exe/a.out poc
>
>
> With the -S flag there is no dropped output or error message at all.
> Omitting -S just drops the compiled object into the file given via the -o
> flag. Here is the output of running my script:
>
> root@llvmbuilder-successful-s-1vcpu-2gb-fra1-01-s-1vcpu-2gb-fra1-01:~/compile/poc#
> LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/llvm-install/lib:~/llvm-install/lib64/
> ./poc_transcript.sh
> gollvm version 1 (experimental)
> Candidate GCC install:
> version: 6.5.0
> foundTriple: x86_64-linux-gnu
> libPath: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
> parentLibPath: /usr/lib/gcc/x86_64-linux-gnu/6.5.0/../..
> installPath: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
> ProgramPaths:
> FilePaths:
> /usr/lib/gcc/x86_64-linux-gnu/6.5.0
> /usr/lib/gcc/x86_64-linux-gnu/6.5.0/../../../x86_64-linux-gnu
>
>
> Anyone got an idea how that happens?
>
> Happy holidays! And thanks for your attention! :)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to