Building the hsail tools.
I had a lot more trouble than this post suggests getting this stuff to compile which is probably why i sound pissed off (hint: i am, actually pro tip: i often am), but this summarises the results.
I started with the instructions in README.hsa from the hsa branch of gcc. See the patches below though.
I installed libelf from slackware 14.1 but had to build libdwarf manually. I got libdwarf-20140208 from the libdwarf home page. I actually created a SlackBuild for it but i'm uncertain about providing it to slackbuilds.org right now (mostly because it seems a bit too niche).
Then this should probably work:
mkdir hsa cd hsa git clone --depth 1 https://github.com/HSAFoundation/HSAIL-Instruction-Set-Simulator.git git clone --depth 1 https://github.com/HSAFoundation/HSAIL-Tools cd HSAIL-Instruction-Set-Simulator/src/ ln -s ../../HSAIL-Tools cd .. mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Debug .. make -j3 _DBG=1 VERBOSE=1
Actually I originally built it from the Okra-Interface-to-HSAIL-Simulator thing, but that checks out both of these tools as part of it's android build process together with the llvm compiler this does. Ugh. And then proceeds to compile whilst hiding the details of what it's actually doing and simultaneously ignoring-all-fatal-errors-along-the-way through the wonders of an ant script. Actually I could add more but I might offend for no purpose - afterall I did get it compiled in the end. I'm just a bit more impatient than I once was :)
Patches
It doesn't look for libelf.h anywhere other than /usr/include so I had to add this to HSAIL-Instruction-Set-Simulator. Of course if you have lib* in /usr/local you have to change it to that instead. Sigh. I thought this sort of auto-discovery was a solved problem.
diff --git a/CMakeLists.txt b/CMakeLists.txt index 083e9c6..c86192c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,9 @@ set(CMAKE_CXX_FLAGS "-DTEST_PATH=${PROJECT_SOURCE_DIR}/test ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-DBIN_PATH=${PROJECT_BINARY_DIR}/HSAIL-Tools ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-DOBJ_PATH=${PROJECT_BINARY_DIR}/test ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-I/usr/include/libdwarf ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "-I/usr/include/libelf ${CMAKE_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -UNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "-O2 -UNDEBUG") # add a target to generate API documentation with Doxygen find_package(Doxygen)
And because I used a newer version of libdwarf than ubuntu uses it has a world-shattering fatal error causing difference in one of the apis.
Apply this to HSAIL-Tools.
diff --git a/libHSAIL/libBRIGdwarf/BrigDwarfGenerator.cpp b/libHSAIL/libBRIGdwarf/BrigDwarfGenerator.cpp index 7e2d28d..fe2bc51 100644 --- a/libHSAIL/libBRIGdwarf/BrigDwarfGenerator.cpp +++ b/libHSAIL/libBRIGdwarf/BrigDwarfGenerator.cpp @@ -261,7 +261,7 @@ public: // bool storeInBrig( HSAIL_ASM::BrigContainer & c ) const; - int DwarfProducerCallback2( char * name, + int DwarfProducerCallback2( const char * name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags, @@ -459,7 +459,7 @@ bool BrigDwarfGenerator_impl::generate( HSAIL_ASM::BrigContainer & c ) // *sec_name_index is an OUT parameter, a pointer to the shared string table // (.shrstrtab) offset for thte name of the section // -static int DwarfProducerCallbackFunc( char * name, +static int DwarfProducerCallbackFunc( const char * name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags, @@ -476,7 +476,7 @@ static int DwarfProducerCallbackFunc( char * name, } int -BrigDwarfGenerator_impl::DwarfProducerCallback2( char * name, +BrigDwarfGenerator_impl::DwarfProducerCallback2( const char * name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags,
I had to use the 'git registry' to disable coloured diffs so I could just see what I was even doing here.
git config --global color.ui false
Whomever thought that sort of bloat was a good idea in such a tool ... well I would only offend if i called him or her a fuckwit wouldn't i?