<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I can think of a reason why this patch would be a bad idea: right now, it's possible for LLVM to be used in the following build workflow:<div><br></div><div>1) Build LLVM with all or most targets and install the static libs wherever (/usr/local, say).</div><div><br></div><div>2) Compile and link a program that uses LLVM, but have it pull in only the static libs for the targets that the program wishes to use.</div><div><br></div><div>With this proposed patch, (2) won't work anymore. You'll get a link error since Target.cpp now requires all of the targets with which LLVM was configured to also be linked by the client.</div><div><br></div><div>-Filip</div><div><br></div><div><br><div><div>On Sep 30, 2013, at 11:51 AM, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I think this is the correct thing to do. Without this a program<br>compiled to use LLVM version X will fail to dynamic link with version<br>X+1 if we drop a target in X+1.<br><br>Bob Wilson, it looks like you added the first of these static inline<br>functions in r74026. Do you remember why you made them inline?<br><br>On 18 September 2013 15:36, Anders Waldenborg <<a href="mailto:anders@0x63.nu">anders@0x63.nu</a>> wrote:<br><blockquote type="cite">wanders added you to the CC list for the revision "request for approval to commit: llvm-c: Make target initializer functions external functions in lib.".<br><br>Hi baldrick,<br><br>Making them proper functions defined in the (shared)lib instead of<br>static inlines defined in the header files makes it possible to<br>actually distribute a binary compiled against the shared library<br>without having to worry about getting undefined symbol errors when<br>calling e.g LLVMInitializeAllTargetInfos because the shared library on<br>the other system was compiled with different targets.<br><br><a href="http://llvm-reviews.chandlerc.com/D1714">http://llvm-reviews.chandlerc.com/D1714</a><br><br>Files:<br> include/llvm-c/Target.h<br> lib/Target/Target.cpp<br><br>Index: include/llvm-c/Target.h<br>===================================================================<br>--- include/llvm-c/Target.h<br>+++ include/llvm-c/Target.h<br>@@ -71,76 +71,41 @@<br> void LLVMInitialize##TargetName##Disassembler(void);<br>#include "llvm/Config/Disassemblers.def"<br>#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */<br>-<br>+<br>/** LLVMInitializeAllTargetInfos - The main program should call this function if<br> it wants access to all available targets that LLVM is configured to<br> support. */<br>-static inline void LLVMInitializeAllTargetInfos(void) {<br>-#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();<br>-#include "llvm/Config/Targets.def"<br>-#undef LLVM_TARGET /* Explicit undef to make SWIG happier */<br>-}<br>+void LLVMInitializeAllTargetInfos(void);<br><br>/** LLVMInitializeAllTargets - The main program should call this function if it<br> wants to link in all available targets that LLVM is configured to<br> support. */<br>-static inline void LLVMInitializeAllTargets(void) {<br>-#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();<br>-#include "llvm/Config/Targets.def"<br>-#undef LLVM_TARGET /* Explicit undef to make SWIG happier */<br>-}<br>+void LLVMInitializeAllTargets(void);<br><br>/** LLVMInitializeAllTargetMCs - The main program should call this function if<br> it wants access to all available target MC that LLVM is configured to<br> support. */<br>-static inline void LLVMInitializeAllTargetMCs(void) {<br>-#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();<br>-#include "llvm/Config/Targets.def"<br>-#undef LLVM_TARGET /* Explicit undef to make SWIG happier */<br>-}<br>-<br>+void LLVMInitializeAllTargetMCs(void);<br>+<br>/** LLVMInitializeAllAsmPrinters - The main program should call this function if<br> it wants all asm printers that LLVM is configured to support, to make them<br> available via the TargetRegistry. */<br>-static inline void LLVMInitializeAllAsmPrinters(void) {<br>-#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();<br>-#include "llvm/Config/AsmPrinters.def"<br>-#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */<br>-}<br>-<br>+void LLVMInitializeAllAsmPrinters(void);<br>+<br>/** LLVMInitializeAllAsmParsers - The main program should call this function if<br> it wants all asm parsers that LLVM is configured to support, to make them<br> available via the TargetRegistry. */<br>-static inline void LLVMInitializeAllAsmParsers(void) {<br>-#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();<br>-#include "llvm/Config/AsmParsers.def"<br>-#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */<br>-}<br>-<br>+void LLVMInitializeAllAsmParsers(void);<br>+<br>/** LLVMInitializeAllDisassemblers - The main program should call this function<br> if it wants all disassemblers that LLVM is configured to support, to make<br> them available via the TargetRegistry. */<br>-static inline void LLVMInitializeAllDisassemblers(void) {<br>-#define LLVM_DISASSEMBLER(TargetName) \<br>- LLVMInitialize##TargetName##Disassembler();<br>-#include "llvm/Config/Disassemblers.def"<br>-#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */<br>-}<br>-<br>+void LLVMInitializeAllDisassemblers(void);<br>+<br>/** LLVMInitializeNativeTarget - The main program should call this function to<br>- initialize the native target corresponding to the host. This is useful<br>+ initialize the native target corresponding to the host. This is useful<br> for JIT applications to ensure that the target gets linked in correctly. */<br>-static inline LLVMBool LLVMInitializeNativeTarget(void) {<br>- /* If we have a native target, initialize it to ensure it is linked in. */<br>-#ifdef LLVM_NATIVE_TARGET<br>- LLVM_NATIVE_TARGETINFO();<br>- LLVM_NATIVE_TARGET();<br>- LLVM_NATIVE_TARGETMC();<br>- return 0;<br>-#else<br>- return 1;<br>-#endif<br>-}<br>+LLVMBool LLVMInitializeNativeTarget(void);<br><br>/*===-- Target Data -------------------------------------------------------===*/<br><br>Index: lib/Target/Target.cpp<br>===================================================================<br>--- lib/Target/Target.cpp<br>+++ lib/Target/Target.cpp<br>@@ -50,6 +50,49 @@<br> initializeTarget(*unwrap(R));<br>}<br><br>+void LLVMInitializeAllTargetInfos(void) {<br>+#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();<br>+#include "llvm/Config/Targets.def"<br>+}<br>+<br>+void LLVMInitializeAllTargets(void) {<br>+#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();<br>+#include "llvm/Config/Targets.def"<br>+}<br>+<br>+void LLVMInitializeAllTargetMCs(void) {<br>+#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();<br>+#include "llvm/Config/Targets.def"<br>+}<br>+<br>+void LLVMInitializeAllAsmPrinters(void) {<br>+#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();<br>+#include "llvm/Config/AsmPrinters.def"<br>+}<br>+<br>+void LLVMInitializeAllAsmParsers(void) {<br>+#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();<br>+#include "llvm/Config/AsmParsers.def"<br>+}<br>+<br>+void LLVMInitializeAllDisassemblers(void) {<br>+#define LLVM_DISASSEMBLER(TargetName) \<br>+ LLVMInitialize##TargetName##Disassembler();<br>+#include "llvm/Config/Disassemblers.def"<br>+}<br>+<br>+LLVMBool LLVMInitializeNativeTarget(void) {<br>+#ifdef LLVM_NATIVE_TARGET<br>+ LLVM_NATIVE_TARGETINFO();<br>+ LLVM_NATIVE_TARGET();<br>+ LLVM_NATIVE_TARGETMC();<br>+ return 0;<br>+#else<br>+ return 1;<br>+#endif<br>+}<br>+<br>+<br>LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) {<br> return wrap(new DataLayout(StringRep));<br>}<br><br>_______________________________________________<br>llvm-commits mailing list<br>llvm-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br><br></blockquote>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></body></html>