Compiler Wrapper Problem (sstcc and sst++)
keitat opened this issue · 1 comments
New Issue for sst-macro
The compiler wrappers of SSTMacro (sstcc/sst++) fails to process any C program.
Building SSTMacro using gcc-7.4.0 (or gcc-10.2.0) on CentOS.
./configure --prefix=
This is a test code.
int main(){
return 1;
}
Here is the output.
./bin/sstcc test.c
In file included from <command-line>:
/home/knteran/SST/sstmacro-nov21/include/sstmac/skeleton.h:53:36: error: expected identifier or '(' before string constant
53 | #define SST_DEFINE_EXE_NAME extern "C" const char exe_main_name[] = SST_APP_NAME_QUOTED;
| ^~~
/home/knteran/SST/sstmacro-nov21/include/sstmac/skeleton.h:212:2: note: in expansion of macro 'SST_DEFINE_EXE_NAME'
212 | SST_DEFINE_EXE_NAME \
| ^~~~~~~~~~~~~~~~~~~
/home/knteran/SST/sstmacro-nov21/include/sstmac/skeleton.h:206:14: note: in expansion of macro 'USER_MAIN'
206 | #define main USER_MAIN
| ^~~~~~~~~
test.c:2:5: note: in expansion of macro 'main'
2 | int main(){
| ^~~~
In file included from <command-line>:
/home/knteran/SST/sstmacro-nov21/include/sstmac/skeleton.h:214:3: error: initializer element is not constant
214 | userSkeletonMainInitFxn(SST_APP_NAME_QUOTED, userSkeletonMain); \
| ^~~~~~~~~~~~~~~~~~~~~~~
/home/knteran/SST/sstmacro-nov21/include/sstmac/skeleton.h:206:14: note: in expansion of macro 'USER_MAIN'
206 | #define main USER_MAIN
| ^~~~~~~~~
test.c:2:5: note: in expansion of macro 'main'
2 | int main(){
| ^~~~
When using sst++, it complains that -fPIC is missing.
[knteran@klogin1 sstmacro-nov21]$ ./bin/sst++ test.c
/usr/bin/ld: test.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
sstcc has been broken for years if clang autoskeleton support is not built. The magic that does the renaming of main() uses code that is only valid in C++. It's probably not impossible to fix, but it doesn't currently seem worth the significant effort required. So I've just made the wrapper generate a useful error message and exit for this case.
Not including -fPIC all the time in the wrapper appears to be a conscious decision, but I can't think of a meaningful disadvantage to just compiling -fPIC always. AFAIK every example Makefile we have for skeletons includes -fPIC in the flags. I didn't see any issues in testing so I've changed the wrappers to just add -fPIC to everything. It will probably save some confusion for new users.