Re: [llvm-commits] CVS: llvm/lib/System/DynamicLibrary.cpp
This bit: +#ifndef errno +EXPLICIT_SYMBOL(errno); +#endif Is broken on Darwin. — Gordon On Jan 19, 2007, at 16:41, Reid Spencer wrote: Changes in directory llvm/lib/System: DynamicLibrary.cpp updated: 1.21 - 1.22 --- Log message: Help the lli interpreter find the stderr/stdin/stdout symbols. These are needed for output to be generated. On Linux these are both global vars and macro definitions so we have to special case Linux. --- Diffs of the changes: (+19 -3) DynamicLibrary.cpp | 22 +++--- 1 files changed, 19 insertions(+), 3 deletions(-) Index: llvm/lib/System/DynamicLibrary.cpp diff -u llvm/lib/System/DynamicLibrary.cpp:1.21 llvm/lib/System/ DynamicLibrary.cpp:1.22 --- llvm/lib/System/DynamicLibrary.cpp:1.21 Fri Jan 19 15:30:39 2007 +++ llvm/lib/System/DynamicLibrary.cpp Fri Jan 19 15:41:04 2007 @@ -164,11 +164,23 @@ } #undef EXPLICIT_SYMBOL #endif + +// This macro returns the address of a well-known, explicit symbol #define EXPLICIT_SYMBOL(SYM) \ if (!strcmp(symbolName, #SYM)) return SYM - // Try a few well known symbols just to give lli a shot at working. - // Note that on some systems stdin, etc. are macros so we have to - // avoid attempting to take the address of a macro :) + +// On linux we have a weird situation. The stderr/out/in symbols are both +// macros and global variables because of standards requirements. So, we +// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. +#if defined(__linux__) + { +EXPLICIT_SYMBOL(stderr); +EXPLICIT_SYMBOL(stdout); +EXPLICIT_SYMBOL(stdin); + } +#else + // For everything else, we want to check to make sure the symbol isn't defined + // as a macro before using EXPLICIT_SYMBOL. { #ifndef stdin EXPLICIT_SYMBOL(stdin); @@ -179,7 +191,11 @@ #ifndef stderr EXPLICIT_SYMBOL(stderr); #endif +#ifndef errno +EXPLICIT_SYMBOL(errno); +#endif } +#endif #undef EXPLICIT_SYMBOL return 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/System/DynamicLibrary.cpp
Hi Gordon, On Fri, 2007-01-19 at 17:01 -0500, Gordon Henriksen wrote: This bit: +#ifndef errno +EXPLICIT_SYMBOL(errno); +#endif Is broken on Darwin. Sorry about that. I reverted that part of the patch. Reid. — Gordon On Jan 19, 2007, at 16:41, Reid Spencer wrote: Changes in directory llvm/lib/System: DynamicLibrary.cpp updated: 1.21 - 1.22 --- Log message: Help the lli interpreter find the stderr/stdin/stdout symbols. These are needed for output to be generated. On Linux these are both global vars and macro definitions so we have to special case Linux. --- Diffs of the changes: (+19 -3) DynamicLibrary.cpp | 22 +++--- 1 files changed, 19 insertions(+), 3 deletions(-) Index: llvm/lib/System/DynamicLibrary.cpp diff -u llvm/lib/System/DynamicLibrary.cpp:1.21 llvm/lib/System/DynamicLibrary.cpp:1.22 --- llvm/lib/System/DynamicLibrary.cpp:1.21 Fri Jan 19 15:30:39 2007 +++ llvm/lib/System/DynamicLibrary.cpp Fri Jan 19 15:41:04 2007 @@ -164,11 +164,23 @@ } #undef EXPLICIT_SYMBOL #endif + +// This macro returns the address of a well-known, explicit symbol #define EXPLICIT_SYMBOL(SYM) \ if (!strcmp(symbolName, #SYM)) return SYM - // Try a few well known symbols just to give lli a shot at working. - // Note that on some systems stdin, etc. are macros so we have to - // avoid attempting to take the address of a macro :) + +// On linux we have a weird situation. The stderr/out/in symbols are both +// macros and global variables because of standards requirements. So, we +// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. +#if defined(__linux__) + { +EXPLICIT_SYMBOL(stderr); +EXPLICIT_SYMBOL(stdout); +EXPLICIT_SYMBOL(stdin); + } +#else + // For everything else, we want to check to make sure the symbol isn't defined + // as a macro before using EXPLICIT_SYMBOL. { #ifndef stdin EXPLICIT_SYMBOL(stdin); @@ -179,7 +191,11 @@ #ifndef stderr EXPLICIT_SYMBOL(stderr); #endif +#ifndef errno +EXPLICIT_SYMBOL(errno); +#endif } +#endif #undef EXPLICIT_SYMBOL return 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/System/DynamicLibrary.cpp
Very Timely. grr. Cheers, -- Jim On 10-Jan-07, at 8:35 PM, Reid Spencer wrote: Changes in directory llvm/lib/System: DynamicLibrary.cpp updated: 1.19 - 1.20 --- Log message: Avoid taking the address of a macro by checking to see if stdin is defined or not. This allows DynamicLibrary.cpp to compile on Darwin. --- Diffs of the changes: (+4 -0) DynamicLibrary.cpp |4 1 files changed, 4 insertions(+) Index: llvm/lib/System/DynamicLibrary.cpp diff -u llvm/lib/System/DynamicLibrary.cpp:1.19 llvm/lib/System/ DynamicLibrary.cpp:1.20 --- llvm/lib/System/DynamicLibrary.cpp:1.19 Wed Jan 10 13:50:43 2007 +++ llvm/lib/System/DynamicLibrary.cppWed Jan 10 18:35:10 2007 @@ -167,10 +167,14 @@ #define EXPLICIT_SYMBOL(SYM) \ if (!strcmp(symbolName, #SYM)) return SYM // Try a few well known symbols just to give lli a shot at working. + // Note that on some systems stdin, etc. are macros so we have to + // avoid attempting to take the address of a macro :) { +#ifndef stdin EXPLICIT_SYMBOL(stdin); EXPLICIT_SYMBOL(stdout); EXPLICIT_SYMBOL(stderr); +#endif } #undef EXPLICIT_SYMBOL ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits