{"size": 1750, "ext": "scrbl", "max_stars_repo_path": "pkgs/racket-doc/scribblings/raco/ext.scrbl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "pkgs/racket-doc/scribblings/raco/ext.scrbl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "pkgs/racket-doc/scribblings/raco/ext.scrbl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": 3, "avg_line_length": 46.0526315789, "max_line_length": 70, "alphanum_fraction": 0.7508571429}
#lang scribble/doc
@(require scribble/manual "common.rkt")

@title[#:tag "ext"]{Compiling to Native Code via C}

The @DFlag{extension}/@Flag{e} mode for @exec{raco ctool} is similar
to the @exec{raco make --zo} (see @secref["zo"]), except that the
compiled form of the module is a native-code shared library instead of
bytecode. Native code is generated with the help of the host system's
C compiler. This mode is rarely useful, because the just-in-time (JIT)
compiler that is built into Racket provides better performance
with lower overhead on the platforms where it is supported (see
@secref[#:doc '(lib "scribblings/guide/guide.scrbl") "performance"]).

As with @DFlag{zo} mode, the generated shared library by default is
placed in the same directory as the source file---which is not where
it will be found automatically when loading the source. Use the
@as-index{@DFlag{auto-dir}} flag to redirect the output to a
@racket[(build-path "compiled" "native" (system-library-subpath))]
subdirectory, where it will be found automatically when loading the
source file.

The @DFlag{c-source}/@Flag{c} mode for @exec{raco ctool} is like the
@DFlag{extension}/@Flag{e} mode, except that compilation stops with
the generation of C code.

All of the C compiler and linker flags that apply to @DFlag{cc} and
@DFlag{ld} mode also apply to @DFlag{extension} mode; see
@secref["cc"].  In addition, a few flag provide some control over the
Racket-to-C compiler: @as-index{@DFlag{no-prop}},
@as-index{@DFlag{inline}}, @as-index{@DFlag{no-prim}},
@as-index{@DFlag{stupid}},
@as-index{@DFlag{unsafe-disable-interrupts}},
@as-index{@DFlag{unsafe-skip-tests}}, and
@as-index{@DFlag{unsafe-fixnum-arithmetic}}. Use @exec{mzc --help} for
an explanation of each flag.

