Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-bc not working #1

Closed
ianamason opened this issue Jun 27, 2017 · 19 comments
Closed

get-bc not working #1

ianamason opened this issue Jun 27, 2017 · 19 comments

Comments

@ianamason
Copy link
Member

OK I have to do some other things, but I can't get get-bc to work on my mac.

It took me a while to get gclang to work, see f42fbca

but now I canna get the bitcode. To reproduce:

cd whole-program-llvm/test/test_files

CC=gclang make many

get-bc main

The problem seems to be that filesToLink is [] @loicgelle

@loicgelle
Copy link
Contributor

@ianamason Is the problem specific to binaries?

@ianamason
Copy link
Member Author

not sure. i'm testing it now on linux. took a while to get my vagrant box up and coughing.
will look into it momentarily.

@ianamason
Copy link
Member Author

No seems to not work pretty uniformly. try some of the simple examples in
whole-program-llvm/test/test_files

CC=gclang make archive
get-bc libfoo.a
CC=gclang make many

get-bc main

etc

@loicgelle
Copy link
Contributor

@ianamason Working on that issue. Bitcode from libraries + objects are extracted fine on Mac, the problem must lie in the method for reading/writing .llvm_bc sections to objects and libraries.

As for binaries, I am not surprised. Look here at line 81: https://github.com/SRI-CSL/whole-program-llvm/blob/master/wllvm/compilers.py

@ianamason
Copy link
Member Author

OK I will let you fix the issue. Yes executable binaries get their section from the linker.
But they still contain sections.

@loicgelle
Copy link
Contributor

@ianamason No problem for me to build/extract objects/libraries in a Linux Docker machine. Probably you did not install llvm tools (like llvm-ar / llvm-link) in your Vagrant box

@loicgelle
Copy link
Contributor

@ianamason My bad, I had to change something in the way the output filename is generated. Checkout the latest commit.

@ianamason
Copy link
Member Author

Nope still doesn't work.

vagrant@vagrant-ubuntu-trusty-64:/vagrant/whole-program-llvm/test/test_files$ CC=gclang make many
gclang foo.c -c
gclang bar.c -c
gclang baz.c -c
gclang main.c -c
gclang foo.o bar.o baz.o main.o -o main
vagrant@vagrant-ubuntu-trusty-64:/vagrant/whole-program-llvm/test/test_files$ get-bc main
2017/06/28 16:58:52 There was an error reading the contents of main. Make sure that the 'objcopy' command is installed.
vagrant@vagrant-ubuntu-trusty-64:/vagrant/whole-program-llvm/test/test_files$ ls -la main.bc
ls: cannot access main.bc: No such file or directory
vagrant@vagrant-ubuntu-trusty-64:/vagrant/whole-program-llvm/test/test_files$ extract-bc main
vagrant@vagrant-ubuntu-trusty-64:/vagrant/whole-program-llvm/test/test_files$ ls -la main.bc
-rw-r--r-- 1 vagrant vagrant 1788 Jun 28 16:59 main.bc
vagrant@vagrant-ubuntu-trusty-64:/vagrant/whole-program-llvm/test/test_files$

@loicgelle
Copy link
Contributor

@ianamason I was saying that I fixed objects and libraries, not binaries. I've just fixed binaries for *nix only and pushed, you can test.

For Mac still not working for some strange reason. Even though I doubt it is related to that, I will try to clean the mess of the extractSectionDarwin function.

@ianamason
Copy link
Member Author

OK gotcha. Still getting the same behaviour, though :-(

@loicgelle
Copy link
Contributor

@ianamason My version of objcopy is 2.28. Can you run objcopy --dump-section .llvm_bc=/dev/stdout main and give me the output? Mine is:

/root/go/src/gllvm/.foo.o.bc
/root/go/src/gllvm/.bar.o.bc
/root/go/src/gllvm/.baz.o.bc
/root/go/src/gllvm/.main.o.bc

@ianamason
Copy link
Member Author

Yes that is what I was doing. My version is 2.24 and it hasn't got that feature :-(

vagrant@vagrant-ubuntu-trusty-64:/vagrant/whole-program-llvm/test/test_files$ objcopy --dump-section .llvm_bc=/dev/stdout main
objcopy: unrecognized option '--dump-section'

@loicgelle
Copy link
Contributor

@ianamason We have to make a choice then. Either we revert back to legacy support, which probably means a messy extracting function like the one for Darwin, or we precise the need for a working version of objcopy.

@ianamason
Copy link
Member Author

I think reverting is better. 14.04 is a pretty popular OS.

@loicgelle
Copy link
Contributor

Why do we have to deal with legacy dinosaurs... Fine then.

Can you try get-bc for Mac? It's working for me in fact

@ianamason
Copy link
Member Author

Yes it seems to work on my mac now.

@loicgelle
Copy link
Contributor

@ianamason Fixed.

@ianamason
Copy link
Member Author

Yep looks good here too.

@loicgelle
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants