|
16 | 16 | ;;
|
17 | 17 | ;; You should have received a copy of the GNU General Public License
|
18 | 18 | ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
| -(require seashell/compiler/ffi |
| 19 | +(require seashell/compiler/ffi seashell/log |
20 | 20 | (submod seashell/seashell-config typed))
|
21 | 21 | (require/typed racket/base
|
22 | 22 | [file-position (case-lambda
|
|
162 | 162 | ;; Remove the object file.
|
163 | 163 | (delete-file object-file)
|
164 | 164 |
|
| 165 | + ;;------------------------------------------------------- |
| 166 | + ;; |
| 167 | + ;; yc2lee's hack to use clang executable instead of |
| 168 | + ;; custom Seashell clang/llvm wrapper |
| 169 | + ;; |
| 170 | + |
| 171 | + (define clang-binary-path (build-path SEASHELL_INSTALL_PATH "bin" "clang-3.9")) |
| 172 | + (when (and (equal? 0 linker-res) |
| 173 | + (file-exists? clang-binary-path) |
| 174 | + (member 'execute (file-or-directory-permissions clang-binary-path))) |
| 175 | + (define clang-binary-arguments |
| 176 | + `("-std=c99" |
| 177 | + "-fsanitize=address" "-fno-omit-frame-pointer" "-fno-common" |
| 178 | + "-g" "-O0" |
| 179 | + ,@(map (lambda ([dir : Path]) (string-append "-I" (path->string dir))) source-dirs) |
| 180 | + "-lm" |
| 181 | + "-o" ,result-file |
| 182 | + ,@(string-split (seashell_compiler_get_dep_paths compiler)))) |
| 183 | + (logf 'info "Running clang compiler: ~a ~a" clang-binary-path clang-binary-arguments) |
| 184 | + ;; Run the clang executable |
| 185 | + (define-values (clang-result clang-stdout clang-stdin clang-stderr) |
| 186 | + (apply subprocess #f #f #f clang-binary-path clang-binary-arguments)) |
| 187 | + (close-output-port clang-stdin) |
| 188 | + ;; Get stdout and stderr contents |
| 189 | + (logf 'info "clang compiler stdout: ~a" (port->string clang-stdout)) |
| 190 | + (close-input-port clang-stdout) |
| 191 | + (logf 'info "clang compiler stderr: ~a" (port->string clang-stderr)) |
| 192 | + (close-input-port clang-stderr) |
| 193 | + (define clang-binary-exit-code (subprocess-status (sync clang-result))) |
| 194 | + (logf 'info "clang compiler exited with code ~a" clang-binary-exit-code)) |
| 195 | + |
| 196 | + ;; |
| 197 | + ;;--------------------------------------------------- |
| 198 | + |
165 | 199 | ;; Read the result:
|
166 | 200 | (define linker-result
|
167 | 201 | (cond
|
|
0 commit comments