[Mesa-dev] [PATCH] radeon/llvm: Convert to Automake
Matt Turner
mattst88 at gmail.com
Fri Aug 31 13:26:33 PDT 2012
On Fri, Aug 31, 2012 at 6:04 AM, Tom Stellard <tom at stellard.net> wrote:
> On Thu, Aug 30, 2012 at 02:11:22PM -0700, Matt Turner wrote:
>> On Thu, Aug 30, 2012 at 1:19 PM, Tom Stellard <tom at stellard.net> wrote:
>> > On Thu, Aug 30, 2012 at 10:47:55AM -0700, Matt Turner wrote:
>> >> On Thu, Aug 30, 2012 at 9:55 AM, <tstellar at gmail.com> wrote:
>> >> > From: Tom Stellard <thomas.stellard at amd.com>
>> >> >
>> >> > ---
>> >> > Hi Matt,
>> >> >
>> >> > This patch applies to your automake-gallium branch.
>> >>
>> >> Thanks a bunch!
>> >>
>> >> > configure.ac | 5 ++
>> >> > src/gallium/drivers/radeon/.gitignore | 1 +
>> >> > src/gallium/drivers/radeon/Makefile | 76 -----------------------
>> >> > src/gallium/drivers/radeon/Makefile.am | 87 +++++++++++++++++++++++++++
>> >> > src/gallium/drivers/radeon/Makefile.sources | 32 ++++++++++-
>> >> > 5 files changed, 124 insertions(+), 77 deletions(-)
>> >> > delete mode 100644 src/gallium/drivers/radeon/Makefile
>> >> > create mode 100644 src/gallium/drivers/radeon/Makefile.am
>> >> >
>> >> > + $(LLVM_CFLAGS)
>> >> > +
>> >> > +CXXFLAGS+= $(LLVM_CXXFLAGS)
>> >>
>> >> Do we really need this? We already have LLVM_CXXFLAGS in AM_CXXFLAGS.
>> >>
>> >
>> > Probably not.
>> >> > +
>> >> > +tablegen = $(LLVM_BINDIR)/llvm-tblgen -I $(LLVM_INCLUDEDIR) $1 $2 -o $3
>> >> > +
>> >> > +libradeon_la_SOURCES = \
>> >> > + $(GENERATED_SOURCES) \
>> >> > + $(CXX_SOURCES) \
>> >> > + $(C_SOURCES)
>> >> > +
>> >> > +CLEANFILES = $(GENERATED_SOURCES)
>> >>
>> >> We should probably set BUILT_SOURCES here.
>> >>
>> >
>> > OK
>> >
>> >> > +
>> >> > +SIRegisterInfo.td: SIGenRegisterInfo.pl
>> >> > + $(PERL) $^ > $@
>> >> > +
>> >> > +SIRegisterGetHWRegNum.inc: SIGenRegisterInfo.pl
>> >> > + $(PERL) $^ $@ > /dev/null
>> >> > +
>> >> > +R600Intrinsics.td: R600IntrinsicsNoOpenCL.td R600IntrinsicsOpenCL.td
>> >> > +if HAVE_R600_LLVM_INTRINSICS
>> >> > + cp R600IntrinsicsNoOpenCL.td R600Intrinsics.td
>> >> > +else
>> >> > + cp R600IntrinsicsOpenCL.td R600Intrinsics.td
>> >> > +endif
>> >> > +
>> >> > +R600RegisterInfo.td: R600GenRegisterInfo.pl
>> >> > + $(PERL) $^ > $@
>> >>
>> >> It's nice to put $(AM_V_GEN) before generator calls.
>> >>
>> >
>> > You mean like:
>> >
>> > $(AM_V_GEN) $(PERL) $^ > $@
>>
>> Yeah, exactly.
>>
>> >> > +
>> >> > +AMDGPUGenRegisterInfo.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-register-info, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenInstrInfo.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-instr-info, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenAsmWriter.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-asm-writer, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenDAGISel.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-dag-isel, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenCallingConv.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-callingconv, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenSubtargetInfo.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-subtarget, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenEDInfo.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-enhanced-disassembly-info, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenIntrinsics.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-tgt-intrinsic, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenCodeEmitter.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-emitter, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenMCCodeEmitter.inc: $(TD_FILES)
>> >> > + $(call tablegen, -mc-emitter -gen-emitter, AMDGPU.td, $@)
>> >> > +
>> >> > +AMDGPUGenDFAPacketizer.inc: $(TD_FILES)
>> >> > + $(call tablegen, -gen-dfa-packetizer, AMDGPU.td, $@)
>> >> > +
>> >> > +noinst_PROGRAMS = loader
>> >> > +
>> >> > +loader_SOURCES = loader.cpp
>> >> > +
>> >> > +loader_LDADD = libradeon.la $(LLVM_LIBS)
>> >> > +loader_LDFLAGS = \
>> >> > + $(LLVM_LDFLAGS) \
>> >> > + $(LD_FLAGS)
>> >> > +
>> >> > +#XXX: Delete this when all targets that rely on radeon are converted to
>> >> > +# automake.
>> >> > +all-local: libradeon.la
>> >> > + ln -f $(builddir)/.libs/libradeon.a $(builddir)/libradeon.a
>> >> > +
>> >> > +CLEANFILES += libradeon.a
>> >> > diff --git a/src/gallium/drivers/radeon/Makefile.sources b/src/gallium/drivers/radeon/Makefile.sources
>> >> > index 687acb3..d8df295 100644
>> >> > --- a/src/gallium/drivers/radeon/Makefile.sources
>> >> > +++ b/src/gallium/drivers/radeon/Makefile.sources
>> >> > @@ -1,4 +1,34 @@
>> >> >
>> >> > +TD_FILES := \
>> >> > + AMDGPU.td \
>> >> > + AMDGPUInstrInfo.td \
>> >> > + AMDGPUInstructions.td \
>> >> > + AMDGPUIntrinsics.td \
>> >> > + AMDGPURegisterInfo.td \
>> >> > + AMDILBase.td \
>> >> > + AMDILInstrInfo.td \
>> >> > + AMDILIntrinsics.td \
>> >> > + AMDILRegisterInfo.td \
>> >> > + Processors.td \
>> >> > + R600InstrInfo.td \
>> >> > + R600Instructions.td \
>> >> > + R600Intrinsics.td \
>> >> > + R600Intrinsics.td \
>> >> > + R600IntrinsicsNoOpenCL.td \
>> >> > + R600IntrinsicsOpenCL.td \
>> >> > + R600OpenCLIntrinsics.td \
>> >> > + R600RegisterInfo.td \
>> >> > + R600RegisterInfo.td \
>> >> > + R600Schedule.td \
>> >> > + SIInstrFormats.td \
>> >> > + SIInstrInfo.td \
>> >> > + SIInstructions.td \
>> >> > + SIIntrinsics.td \
>> >> > + SIRegisterInfo.td \
>> >> > + SIRegisterInfo.td \
>> >> > + SISchedule.td
>> >> > +
>> >> > +
>> >> > GENERATED_SOURCES := \
>> >> > R600Intrinsics.td \
>> >> > R600RegisterInfo.td \
>> >> > @@ -16,7 +46,7 @@ GENERATED_SOURCES := \
>> >> > AMDGPUGenMCCodeEmitter.inc \
>> >> > AMDGPUGenDFAPacketizer.inc
>> >> >
>> >> > -CPP_SOURCES := \
>> >> > +CXX_SOURCES := \
>> >> > AMDIL7XXDevice.cpp \
>> >> > AMDILCFGStructurizer.cpp \
>> >> > AMDILDevice.cpp \
>> >> > --
>> >> > 1.7.7.6
>> >>
>> >> When I build with this, I get:
>> >>
>> >> CXX AMDIL7XXDevice.lo
>> >> In file included from AMDIL7XXDevice.cpp:10:0:
>> >> AMDGPUSubtarget.h:22:38: fatal error: AMDGPUGenSubtargetInfo.inc: No
>> >> such file or directory
>> >> compilation terminated.
>> >> make: *** [AMDIL7XXDevice.lo] Error 1
>> >>
>> >> and seeing AMDGPUGenSubtargetInfo.inc in GENERATED_SOURCES, if I try to make it:
>> >>
>> >> make: *** No rule to make target `R600InstrInfo.td', needed by
>> >> `AMDGPUGenSubtargetInfo.inc'. Stop.
>> >>
>> >> After removing R600InstrInfo.td, R600IntrinsicsOpenCL.td, and
>> >> R600OpenCLIntrinsics.td from TD_FILES in Makefile.sources,
>> >> AMDIL7XXDevice.lo still fails to build, but I can now build
>> >> AMDGPUGenSubtargetInfo.inc.
>> >>
>> >> So, we either need to do more finely grained dependencies on *.inc
>> >> files, or put BUILT_SOURCES = $(GENERATED_SOURCES) to make sure
>> >> everything is generated before we start compiling. The first would
>> >> allow slightly better parallelism in the build, but the second is much
>> >> easier.
>> >>
>> >
>> > Let's do BUILT_SOURCES = $(GENERATED_SOURCES) for now. Do you want me
>> > to send you a new patch, or have you already made these changes locally?
>>
>> Works for me. Even with the changes I made, I couldn't get loader to
>> link, so you might want to look at that. If the fix is simple, just
>> tell me what it is and I'll fix these things locally.
>
> The loader program is only for debugging and is not built by default in
> Mesa master. If it is the only blocker you have you can remove it
> from the default build, and actually since it can take a while to link
> when using debug builds, it probably shouldn't be built by default
> anyway.
>
> I can still take a look at fixing the linking problems, but I need
> to know:
> 1. What are the errors?
> 2. What version of LLVM are you using?
> 3. What prefix do you have LLVM installed in?
>
> -Tom
Of course. Sorry -- I thought you would be able to reproduce locally.
The error is
gmake[1]: Entering directory
`/home/mattst88/projects/mesa/src/gallium/drivers/radeon'
/bin/sh ../../../../libtool --tag=CXX --mode=link g++
-I/usr/include -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-fvisibility-inlines-hidden -fno-exceptions -fPIC -Woverloaded-virtual
-Wcast-qual -O0 -pipe -Wall -fno-strict-aliasing -fno-builtin-memcmp
-L/usr/lib64/llvm -lpthread -lffi -ldl -lm -o loader loader.o
libradeon.la -lLLVMMCJIT -lLLVMBitWriter -lLLVMX86CodeGen
-lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86AsmParser -lLLVMMCParser
-lLLVMX86Disassembler -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter
-lLLVMX86Utils -lLLVMJIT -lLLVMRuntimeDyld -lLLVMExecutionEngine
-lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils
-lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore
-lLLVMSupport
libtool: link: g++ -I/usr/include -DNDEBUG -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-fvisibility-inlines-hidden -fno-exceptions -fPIC -Woverloaded-virtual
-Wcast-qual -O0 -pipe -Wall -fno-strict-aliasing -fno-builtin-memcmp
-o loader loader.o -L/usr/lib64/llvm -lpthread -lffi -ldl -lm
./.libs/libradeon.a -lLLVMMCJIT -lLLVMBitWriter -lLLVMX86CodeGen
-lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86AsmParser -lLLVMMCParser
-lLLVMX86Disassembler -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter
-lLLVMX86Utils -lLLVMJIT -lLLVMRuntimeDyld -lLLVMExecutionEngine
-lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils
-lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore
-lLLVMSupport
loader.o: In function `llvm::ParseIR(llvm::MemoryBuffer*,
llvm::SMDiagnostic&, llvm::LLVMContext&)':
loader.cpp:(.text._ZN4llvm7ParseIREPNS_12MemoryBufferERNS_12SMDiagnosticERNS_11LLVMContextE[llvm::ParseIR(llvm::MemoryBuffer*,
llvm::SMDiagnostic&, llvm::LLVMContext&)]+0x80): undefined reference
to `llvm::ParseBitcodeFile(llvm::MemoryBuffer*, llvm::LLVMContext&,
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>*)'
loader.cpp:(.text._ZN4llvm7ParseIREPNS_12MemoryBufferERNS_12SMDiagnosticERNS_11LLVMContextE[llvm::ParseIR(llvm::MemoryBuffer*,
llvm::SMDiagnostic&, llvm::LLVMContext&)]+0x185): undefined reference
to `llvm::ParseAssembly(llvm::MemoryBuffer*, llvm::Module*,
llvm::SMDiagnostic&, llvm::LLVMContext&)'
collect2: ld returned 1 exit status
I'm using llvm-3.1 from my distribution, which means the prefix is /usr.
If it's useful, I'm able to build working LLVMpipe using my automake patches.
To confirm, should I remove R600InstrInfo.td, R600IntrinsicsOpenCL.td,
and R600OpenCLIntrinsics.td from TD_FILES?
More information about the mesa-dev
mailing list