2688 | | // compiler by default. We prefer to use clang instead (set by means of |
2689 | | // the PATSCCOMP environment variable). If you have a working dragonegg |
2690 | | // plugin installed, you can still override this by setting the PURE_ATSCC |
2691 | | // variable to 'patscc -fplugin=dragonegg'. NOTE: In any case you should |
2692 | | // set the PATSHOME environment variable as explained in the ATS2 |
2693 | | // installation instructions. |
| 2690 | // compiler by default. We prefer to use clang instead. If you have a |
| 2691 | // working dragonegg plugin installed, you can still override this by |
| 2692 | // setting the PURE_ATSCC variable to 'patscc -fplugin=dragonegg'. NOTE: |
| 2693 | // In any case you should set the PATSHOME environment variable as |
| 2694 | // explained in the ATS2 installation instructions. |
2699 | | // We only override patscc's default C compiler if neither PURE_ATSCC nor |
2700 | | // PATSCCOMP has been set, so that the user still has full control over |
2701 | | // which AST and C compilers will be used. |
2702 | | if (!getenv("PURE_ATSCC") && !getenv("PATSCCOMP")) { |
2703 | | static char *patsccomp = NULL; |
2704 | | if (!patsccomp) { |
2705 | | string ccomp = string("PATSCCOMP=") + clang + " -emit-llvm -std=c99 -D_XOPEN_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime"; |
2706 | | patsccomp = strdup(ccomp.c_str()); |
2707 | | putenv(patsccomp); |
2708 | | } |
2709 | | args = " -c "; |
| 2699 | // Unless dragonegg is being used or PURE_ATSCCOMP has been set |
| 2700 | // explicitly, we override patscc's default C compiler so that clang is |
| 2701 | // used to generate bitcode. If needed, this gives the user full control |
| 2702 | // over which AST and C compilers will be used, and the options they |
| 2703 | // should be invoked with. The options needed for bitcode compilation are |
| 2704 | // always added, however. |
| 2705 | char *atscc = getenv(env); |
| 2706 | char *atsccomp = getenv("PURE_ATSCCOMP"); |
| 2707 | // Figure out the default C compiler to use and set up command line |
| 2708 | // arguments accordingly. |
| 2709 | string cc = clang+ " -emit-llvm"; |
| 2710 | args = " -atsccomp \"${PURE_ATSCCOMP}\" -c "; |
| 2711 | if (atscc && strstr(atscc, "dragonegg")) { |
| 2712 | // Use dragonegg instead. |
| 2713 | cc = "gcc"; |
| 2714 | args = " -atsccomp \"${PURE_ATSCCOMP}\" -emit-llvm -c "; |
| 2715 | } |
| 2716 | if (!atsccomp) { |
| 2717 | // Set up a reasonable default for the PURE_ATSCCOMP variable. |
| 2718 | string ccomp = string("PURE_ATSCCOMP=") + cc + " -std=c99 -D_XOPEN_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime"; |
| 2719 | atsccomp = strdup(ccomp.c_str()); |
| 2720 | putenv(atsccomp); |
| 2721 | bool vflag = (verbose&verbosity::compiler) != 0; |
| 2722 | if (vflag) std::cerr << atsccomp << '\n'; |