[llvm-dev] How to generate .bc file using configure && make on Mac OS X?

Peng Yu via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 28 11:53:38 PST 2019


Here are some of my environment.

$ which clang
/Library/Developer/CommandLineTools/usr/bin/clang
$  clang --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ which lli
/usr/local/opt/llvm/bin/lli
$ /usr/local/opt/llvm/bin/clang --version
clang version 7.0.1 (tags/RELEASE_701/final)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

I rerun the exact commands that you used. But I still get the error.

Does setting LLVM_COMPILER_PATH ensure the correct version of compiler
be used? Thanks.

export LLVM_COMPILER_PATH=/usr/local/opt/llvm/bin
export CC=gclang
../bash-5.0/configure && make -j2
for i in $(find . -executable -and -type f) ; do echo $i ; extract-bc $i ; done
$ lli bash.bc -c "echo 'test''"
Stack dump:
0.    Program arguments: lli bash.bc -c echo 'test''
0  lli                      0x0000000102808922
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  lli                      0x0000000102808d26 SignalHandler(int) + 200
2  libsystem_platform.dylib 0x00007fff7d6daf5a _sigtramp + 26
3  libsystem_platform.dylib 0x00000001037c9080 _sigtramp + 2249122112
4  lli                      0x000000010258a045
llvm::MCJIT::runFunction(llvm::Function*,
llvm::ArrayRef<llvm::GenericValue>) + 535
5  lli                      0x000000010251cae7
llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*,
std::__1::vector<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >,
std::__1::allocator<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > > > const&,
char const* const*) + 1159
6  lli                      0x0000000102249b84 main + 9104
7  libdyld.dylib            0x00007fff7d3cc015 start + 1
8  libdyld.dylib            0x0000000000000004 start + 2193833968
Segmentation fault: 11


On Mon, Jan 28, 2019 at 1:31 PM Jakub (Kuba) Kuderski
<kubakuderski at gmail.com> wrote:
>
> It did work for me with llvm-5.0. I don't have time run it on newer versions.
>
> ```
> wget https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz
> tar xvf bash-5.0.tar.gz
> cd bash-5.0
> mkdir build; cd build
> export LLVM_COMPILER_PATH=my_llvm_dir/bin
> export CC=gclang
> export CXX=gclang++
> ../configure
> make -j32
> for i in $(find . -executable -and -type f) ; do echo $i ; extract-bc $i ; done
> lli bash.bc -c "echo 'test''"
> ```
>
> On Mon, Jan 28, 2019 at 1:44 PM Peng Yu <pengyu.ut at gmail.com> wrote:
>>
>> Could you try the bash source code to see if you see the same errors?
>> It should just take a few minutes to configure/compile. Thanks.
>>
>> https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz
>>
>> > I did a sanity check and run some of the bitcode I complied with gllvm and it seems to work fine under lli. The only issues is to make sure you load all the (external) libraries the bitcode needs. I highly suggest you run a debug version of lli under a debugger and see what exactly happens.
>>
>> --
>> Regards,
>> Peng
>
>
>
> --
> Jakub Kuderski



-- 
Regards,
Peng


More information about the llvm-dev mailing list