Changeset 35528 in project
- Timestamp:
- 05/07/18 16:20:06 (10 months ago)
- Location:
- wiki/man/5
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
wiki/man/5/Deployment
r35472 r35528 82 82 and place them in the application directory. 83 83 84 === Distributing compiled C files 85 86 It is possible to create distributions of Scheme projects that 87 have been compiled to C. The runtime system of CHICKEN consists of only 88 two handcoded C files ({{runtime.c}} and {{chicken.h}}), plus the files 89 {{chicken-config.h}} and {{buildtag.h}}, which are generated by the 90 build process. All other modules of the runtime system and the extension 91 libraries are just compiled Scheme code. The following example shows a 92 minimal application, which should run without changes on most operating 93 systems, like Windows, Linux or FreeBSD (note however that static 94 binaries are not supported on Mac OS X). 95 96 Take the following "Hello World" program: 97 98 <enscript highlight=scheme> 99 ; hello.scm 100 101 (print "Hello, world!") 102 </enscript> 103 104 % csc -t hello.scm -optimize-level 3 -output-file hello.c 105 106 Compiled to C, we get {{hello.c}}. We need the files {{chicken.h}}, 107 {{chicken-config.h}}, {{buildtag.h}} and {{runtime.c}}, which contain 108 the basic runtime system, plus the library files {{build-version.c}}, 109 {{chicken-syntax.c}}, {{eval.c}}, {{expand.c}}, {{internal.c}}, 110 {{library.c}} and {{modules.c}}, which contain the same functionality as 111 the library that is linked into plain CHICKEN-compiled applications: 112 113 % cd /tmp 114 % echo '(print "Hello World.")' > hello.scm 115 % csc -t hello.scm 116 % cp $CHICKEN_BUILD/build-version.c . 117 % cp $CHICKEN_BUILD/chicken-syntax.c . 118 % cp $CHICKEN_BUILD/eval.c . 119 % cp $CHICKEN_BUILD/expand.c . 120 % cp $CHICKEN_BUILD/internal.c . 121 % cp $CHICKEN_BUILD/library.c . 122 % cp $CHICKEN_BUILD/modules.c . 123 % cp $CHICKEN_BUILD/runtime.c . 124 % cp $CHICKEN_BUILD/chicken.h . 125 % cp $CHICKEN_BUILD/chicken-config.h . 126 % cp $CHICKEN_BUILD/buildtag.h . 127 % gcc -Os -fomit-frame-pointer -DHAVE_CHICKEN_CONFIG_H hello.c \ 128 build-version.c eval.c expand.c internal.c library.c modules.c runtime.c \ 129 -o hello -lm 130 131 Once we have all the files together, we can create a tarball: 132 133 % tar czf hello.tar.gz hello.c build-version.c chicken-syntax.c eval.c \ 134 expand.c internal.c library.c modules.c runtime.c chicken.h \ 135 chicken-config.h buildtag.h 136 137 This is naturally rather simplistic. Things like enabling dynamic 138 loading and selecting supported features of the host system would need 139 more configuration- and build-time support. All this can be addressed 140 using more elaborate build-scripts, makefiles or by using 141 autoconf/automake. 142 143 The {{chicken-config.h}} file may contain incorrect settings for your 144 deployment target. Especially when the architecture is different. In 145 that case you will have to adjust the values as needed. 146 147 For more information, study the CHICKEN source code and/or ask on the CHICKEN 148 mailing lists to understand the implications and difficulties of this deployment 149 method in more detail. 150 84 151 === Platform specific notes 85 152 -
wiki/man/5/Extensions
r35525 r35528 265 265 266 266 --- 267 Previous: [[ Interface to external functions and variables]]267 Previous: [[Declarations]] 268 268 269 269 Next: [[Extension tools]] -
wiki/man/5/Interface to external functions and variables
r35525 r35528 20 20 Previous: [[Included modules]] 21 21 22 Next: [[ Extensions]]22 Next: [[Declarations]] -
wiki/man/5/The User's Manual
r35527 r35528 16 16 * [[Included modules]] : A reference to CHICKEN's core module library 17 17 * [[Interface to external functions and variables]] : Accessing C/C++ code and data 18 * [[Declarations]] : Compiler declarations 18 19 * [[Extensions]] : Packaging and installing extension libraries 19 20 * [[Extension tools]] : {{chicken-[un]install}} and {{chicken-status}} -
wiki/man/5/Using the compiler
r35525 r35528 15 15 === Compiler command line format 16 16 17 c sc FILENAME-OR-OPTION17 chicken FILENAME OPTION ... 18 18 19 19 {{FILENAME}} is the pathname of the source file that is to … … 25 25 ; -analyze-only : Stop compilation after first analysis pass. 26 26 27 ; -block : Enable block-compilation. When this option is specified, the compiler assumes that global variables are not modified outside this compilation-unit. Specifically, toplevel bindings are not seen by {{eval}} and unused toplevel bindings are removed.27 ; -block : Enable block-compilation. When this option is specified, the compiler assumes that global variables are not modified outside of this compilation-unit. Specifically, toplevel bindings are not seen by {{eval}} and unused toplevel bindings are removed. 28 28 29 29 ; -case-insensitive : Enables the reader to read symbols case insensitive. The default is to read case sensitive (in violation of R5RS). This option registers the {{case-insensitive}} feature identifier. … … 37 37 ; -debug MODES : Enables one or more compiler debugging modes. {{MODES}} is a string of characters that select debugging information about the compiler that will be printed to standard output. Use {{-debug h}} to see a list of available debugging options. 38 38 39 ; -debug-level LEVEL : Selects amount of debug-information. {{LEVEL}} should be an integer. 40 41 -debug-level 0 is equivalent to -no-trace -no-lambda-info 42 -debug-level 1 is equivalent to -no-trace 43 -debug-level 2 is the default behaviour 44 -debug-level 3 is equivalent to -debug-info 45 46 ; -disable-interrupts : Equivalent to the {{(disable-interrupts)}} declaration. No interrupt-checks are generated for compiled programs. 39 ; -debug-level LEVEL : Selects amount of debug-information. {{LEVEL}} should be an integer, where {{0}} is equivalent to {{-no-trace -no-lambda-info}}, {{1}} is equivalent to {{-no-trace}}, {{2}} is the default behaviour and {{3}} is equivalent to {{-debug-mode}}. 40 41 ; -disable-interrupts : Equivalent to the {{(disable-interrupts)}} declaration. No interrupt-checks are generated for compiled programs, which disables thread context switches in this (and only this) compilation unit. 47 42 48 43 ; -disable-stack-overflow-checks : Disables detection of stack overflows. This is equivalent to running the compiled executable with the {{-:o}} runtime option. … … 70 65 ; -feature SYMBOL : Registers {{SYMBOL}} to be a valid feature identifier for {{cond-expand}}. Multiple symbols may be given, if comma-separated. 71 66 72 ; -fixnum-arithmetic : Equivalent to {{(fixnum-arithmetic)}} declaration. Assume all mathematical operations use small integer arguments.73 74 ; -heap-size NUMBER : Sets a fixed heap size of the generated executable to {{NUMBER}} bytes. The parameter may be followed by a {{M}} ({{m}}) or {{K}} ({{k}}) suffix which stand for mega- and kilobytes, respectively. The default heap size is 5 kilobytes. Note that only half of it is in use at every given time.67 ; -fixnum-arithmetic : Equivalent to the {{(fixnum-arithmetic)}} declaration. Assume all mathematical operations use small integer arguments. 68 69 ; -heap-size NUMBER : Sets a fixed heap size of {{NUMBER}} bytes for the generated executable. The parameter may be followed by a {{M}} ({{m}}) or {{K}} ({{k}}) suffix which stand for mega- and kilobytes, respectively. The default heap size is 500 kilobytes. Note that only half of it is in use at every given time. Note also that by default the heap is dynamically resized unless this option is given. 75 70 76 71 ; -help : Print a summary of available options and the format of the command line parameters and exit the compiler. 77 72 78 ; -ignore-repository : Do not load any extensions from the repository (treat repository as empty). Also do not consult compiled (only interpreted) import libraries in {{import}} forms.79 80 ; -include-path PATHNAME : Specifies an additional search path for files included via the {{include}} special form. This option may be given multiple times. If the environment variable {{CHICKEN_INCLUDE_PATH}} is set, it should contain a list of alternative include pathnames separated by {{:}} ( unix) or {{;}} (windows).73 ; -ignore-repository : Do not load any extensions from the repository (treat the repository as empty). Also do not consult compiled (only interpreted) import libraries in {{import}} forms. 74 75 ; -include-path PATHNAME : Specifies an additional search path for files included via the {{include}} special form. This option may be given multiple times. If the environment variable {{CHICKEN_INCLUDE_PATH}} is set, it should contain a list of alternative include pathnames separated by {{:}} (UNIX) or {{;}} (Windows). 81 76 82 77 ; -inline : Enable procedure inlining for known procedures of a size below the threshold (which can be set through the {{-inline-limit}} option). … … 86 81 ; -inline-limit THRESHOLD : Sets the maximum size of a potentially inlinable procedure. The default threshold is {{20}}. 87 82 88 ; -keyword-style STYLE : Enables alternative keyword syntax, where {{STYLE}} may be either {{prefix}} (as in Common Lisp, e.g. :keyword), {{suffix}} (as in DSSSL, e.g. keyword:) or {{none}} . Any other value is ignored. The default is {{suffix}}.83 ; -keyword-style STYLE : Enables alternative keyword syntax, where {{STYLE}} may be either {{prefix}} (as in Common Lisp, e.g. :keyword), {{suffix}} (as in DSSSL, e.g. keyword:) or {{none}} (where only the {{#:KEYWORD}} is allowed). Any other value is ignored. The default is {{suffix}}. 89 84 90 85 ; -keep-shadowed-macros : Do not remove macro definitions with the same name as assigned toplevel variables (the default is to remove the macro definition). … … 102 97 ; -no-bound-checks : disable bound variable checks 103 98 104 ; -no-feature SYMBOL : Disables the predefined feature-identifier {{SYMBOL}}. Multiple symbols may be given, if comma-separated.105 106 ; -no-lambda-info : Do n't emit additional information for each {{lambda}} expression (currently the argument-list, after alpha-conversion/renaming).107 108 ; -no-module-registration : Do not generate module-registration code in the compiled code. This is only needed if you want to use an import library that is generated by other means (manually, for example).99 ; -no-feature SYMBOL : Disables the predefined feature-identifier {{SYMBOL}}. Multiple comma-separated symbols may be given. 100 101 ; -no-lambda-info : Do not emit additional information for each {{lambda}} expression (currently the argument-list, after alpha-conversion/renaming). 102 103 ; -no-module-registration : Do not generate module-registration code in the compiled code. This is needed if you want to use an import library that is generated by other means (manually, for example), or when you do not intend to use modules in the program at runtime (using {{eval}}). 109 104 110 105 ; -no-parentheses-synonyms : Disables list delimiter synonyms, [..] and {...} for (...). … … 127 122 ; -optimize-leaf-routines : Enable leaf routine optimization. 128 123 129 ; -optimize-level LEVEL : Enables certain sets of optimization options. {{LEVEL}} should be an integer. 130 131 -optimize-level 0 is equivalent to -no-usual-integrations -no-compiler-syntax 132 -optimize-level 1 is equivalent to -optimize-leaf-routines 133 -optimize-level 2 is equivalent to -optimize-leaf-routines -inline 134 -optimize-level 3 is equivalent to -optimize-leaf-routines -local -inline -inline-global -specialize 135 -optimize-level 4 is equivalent to -optimize-leaf-routines -local -inline -inline-global -specialize -unsafe 136 -optimize-level 5 is equivalent to -optimize-leaf-routines -block -inline -inline-global -specialize -unsafe -disable-interrupts -no-trace -no-lambda-info -clustering -lfa2 137 138 ; -output-file FILENAME : Specifies the pathname of the generated C file. Default is {{FILENAME.c}}. 124 ; -optimize-level LEVEL : Enables certain sets of optimization options. {{LEVEL}} should be an integer. Level {{0}} is equivalent to {{-no-usual-integrations -no-compiler-syntax}} (no optimization), level {{1} is equivalent to {{-optimize-leaf-routines}} (minimal optimization), level {{2}} is equivalent to {{-optimize-leaf-routines -inline}} (enable optimizations that do not break standard compliance, this is the default), level {{3}} is equivalent to {{-optimize-leaf-routines -local -inline -inline-global -specialize}} (maximal optimization, while still "safe"), level {{4}} is equivalent to {{-optimize-leaf-routines -local -inline -inline-global -specialize -unsafe}} (maximal optimization, "unsafe") and any higher level is equivalent to {{-optimize-leaf-routines -block -inline -inline-global -specialize -unsafe -disable-interrupts -no-trace -no-lambda-info -clustering -lfa2}} (all possible optimizations, "unsafe"). 125 126 ; -output-file FILENAME : Specifies the pathname of the generated C file. Default is to use the source filename with the extension replaced by {{.c}}. 139 127 140 128 ; -postlude EXPRESSIONS : Add {{EXPRESSIONS}} after all other toplevel expressions in the compiled file. This option may be given multiple times. Processing of this option takes place after processing of {{-epilogue}}. … … 143 131 144 132 ; -profile : 145 ; -accumulate-profile : Instruments the source code to count procedure calls and execution times. After the program terminates (either via an explicit {{exit}} or implicitly), profiling statistics are written to a file named {{PROFILE.<randomnumber>}}. Each line of the generated file contains a list with the procedure name, the number of calls and the time spent executing it. Use the {{chicken-profile}} program to display the profiling information in a more user-friendly form. Enter {{chicken-profile -help}} at the command line to get a list of available options. The {{-accumulate-profile}} option is similar to {{-profile}}, but the resulting profile information will be appended to any existing {{PROFILE}} file. {{chicken-profile}} will merge and sum up the accumulated timing information, if several entries for the same procedure calls exist. Only profiling information for global procedures will be collected. See the {{-:p}} option under [[# runtime-options|"Runtime options"]] below for statistical profiling support.133 ; -accumulate-profile : Instruments the source code to count procedure calls and execution times. After the program terminates (either via an explicit {{exit}} or implicitly), profiling statistics are written to a file named {{PROFILE.<randomnumber>}}. Each line of the generated file contains a list with the procedure name, the number of calls and the time spent executing it. Use the {{chicken-profile}} program to display the profiling information in a more user-friendly form. Enter {{chicken-profile -help}} at the command line to get a list of available options. The {{-accumulate-profile}} option is similar to {{-profile}}, but the resulting profile information will be appended to any existing {{PROFILE}} file. {{chicken-profile}} will merge and sum up the accumulated timing information, if several entries for the same procedure calls exist. Only profiling information for global procedures will be collected. See the {{-:p}} option under [[#Runtime options|"Runtime options"]] below for statistical profiling support. 146 134 147 135 ; -profile-name FILENAME : Specifies name of the generated profile information (which defaults to {{PROFILE.<randomnumber>}}. Implies {{-profile}}. … … 149 137 ; -prologue FILENAME : Includes the file named {{FILENAME}} at the start of the compiled source file. The include-path is not searched. This option may be given multiple times. 150 138 151 ; -r5rs-syntax : Disables the CHICKEN extensions to R5RS syntax. Does not disable [[Non-standard read syntax|non-standard read syntax]].152 153 ; -raw : Disables the generation of any implicit code that uses the Scheme libraries (that is all runtime system files besides {{runtime.c}} and {{chicken.h}}). 139 ; -r5rs-syntax : Disables the CHICKEN extensions to R5RS syntax. Does not disable non-standard read syntax. 140 141 ; -raw : Disables the generation of any implicit code that uses the Scheme libraries (that is all runtime system files besides {{runtime.c}} and {{chicken.h}}). Use this only when you know what you are doing. 154 142 155 143 ; -require-extension NAME : Loads the extension {{NAME}} before the compilation process commences. This is identical to adding {{(require-extension NAME)}} at the start of the compiled program. If {{-uses NAME}} is also given on the command line, then any occurrences of {{-require-extension NAME}} are replaced with {{(declare (uses NAME))}}. Multiple names may be given and should be separated by commas. … … 161 149 ; -static : Link extensions statically, if possible. 162 150 163 ; -strict-types : Assume that the type of variables is not changed by assignments. This gives more type-information during specialization, but violating this assumption will result in unsafe and incorrectly behaving code. 151 ; -strict-types : Assume that the type of variables is not changed by assignments. This gives more type-information during specialization, but violating this assumption will result in unsafe and incorrectly behaving code. Use with care. 164 152 165 153 ; -consult-types-file FILENAME : load additional type database from {{FILENAME}}. Type-definitions in {{FILENAME}} will override previous type-definitions. … … 173 161 ; -unsafe : Disable runtime safety checks. 174 162 175 ; -uses NAME : Use definitions from the library unit {{NAME}}. This is equivalent to {{-prelude "(declare (uses NAME))"}}. Multiple arguments may be given, separated by {{,}} .163 ; -uses NAME : Use definitions from the library unit {{NAME}}. This is equivalent to {{-prelude "(declare (uses NAME))"}}. Multiple arguments may be given, separated by {{,}} (comma). 176 164 177 165 ; -no-usual-integrations : Specifies that standard procedures and certain internal procedures may be redefined, and can not be inlined. This is equivalent to declaring {{(not usual-integrations)}}. … … 196 184 After successful compilation a C source file is generated and can be 197 185 compiled with a C compiler. Executables generated with CHICKEN (and the 198 compiler itself) accept a small set of runtime options: 186 compiler itself) accept a small set of runtime options. These are filtered out 187 by the startup code and will not be contained in the result of 188 {{(command-line-arguments)}}. 199 189 200 190 ; {{-:?}} : Shows a list of the available runtime options and exits the program. … … 202 192 ; {{-:aNUMBER}} : Specifies the length of the buffer for recording a trace of the last invoked procedures. Defaults to 16. 203 193 204 ; {{-:ANUMBER}} : Specifies fixed "temporary stack" size. This is used mostly for {{apply}}. If you supply a zero size (the default), thestack will be dynamically reallocated as needed.194 ; {{-:ANUMBER}} : Specifies fixed ''temporary stack'' size. This is used mostly for {{apply}}. If you supply a zero size (the default), the temorary stack will be dynamically reallocated as needed. 205 195 206 196 ; {{-:b}} : Enter a read-eval-print-loop when an error is encountered. 207 197 208 ; {{-:B}} : Sounds a bell ( ASCII 7) on every major garbage collection.198 ; {{-:B}} : Sounds a bell (by writing ASCII 7 to stdout) on every major garbage collection. 209 199 210 200 ; {{-:c}} : Forces console mode. Currently this is only used in the interpreter ({{csi}}) to force output of the {{#;N>}} prompt even if stdin is not a terminal (for example if running in an {{emacs}} buffer under Windows). … … 216 206 ; {{-:g}} : Prints information about garbage-collection. 217 207 218 ; {{-:G}} : Force GUI mode (show error messages in dialog box , suitable for platform).208 ; {{-:G}} : Force GUI mode (show error messages in dialog box if running under MacOS X or Windows). 219 209 220 210 ; {{-:H}} : Before terminating, dump heap usage to stderr. … … 238 228 ; {{-:PFREQUENCY}} : Same as {{-:p}} but set the sampling frequency in microseconds (default is 10000 microseconds or every 10 milliseconds). 239 229 240 ; {{-:r}} : Writes trace output to stderr. This option has no effect within files compiled with the {{-no-trace}} options.230 ; {{-:r}} : Writes trace output to stderr. This option has no effect in files compiled with the {{-no-trace}} options. 241 231 242 232 ; {{-:sNUMBER}} : Specifies stack size. 243 233 244 234 ; {{-:tNUMBER}} : Specifies symbol table size. 245 246 ; {{-:w}} : Enables garbage collection of unused symbols. By default unused and unbound symbols are not garbage collected.247 235 248 236 ; {{-:x}} : Raises uncaught exceptions of separately spawned threads in primordial thread. By default uncaught exceptions in separate threads are not handled, unless the primordial one explicitly joins them. When warnings are enabled (the default) and {{-:x}} is not given, a warning will be shown, though. … … 254 242 255 243 Runtime options may be combined, like {{-:dc}}, but everything following 256 an argument is ignored. So {{-:wh64m}} is OK, but {{-:h64mw}} will not 257 enable GC of unused symbols. 258 259 === Examples 260 261 ==== A simple example (with one source file) 262 263 To compile a Scheme program (assuming a UNIX-like environment) consisting of a single source file, perform the following steps. 264 265 ===== Writing your source file 266 267 In this example we will assume your source file is called {{foo.scm}}: 268 269 <enscript highlight=scheme> 270 ;;; foo.scm 271 272 (define (fac n) 273 (if (zero? n) 274 1 275 (* n (fac (- n 1))) ) ) 276 277 (write (fac 10)) 278 (newline) 279 </enscript> 280 281 ===== Compiling your program 282 283 Compile the file {{foo.scm}}: 284 285 % csc foo.scm 286 287 This will produce the {{foo}} executable: 288 289 % ls 290 foo foo.scm 291 292 ===== Running your program 293 294 To run your newly compiled executable use: 295 296 % ./foo 297 3628800 298 299 300 ==== An example with multiple files 301 302 If multiple bodies of Scheme code are to be combined into a single 303 executable, then we have to compile each file and link the resulting 304 object files together with the runtime system. 305 306 Let's consider an example where your program consists of multiple source files. 307 308 ===== Writing your source files 309 310 The declarations in these files specify which of the compiled files is the main 311 module, and which is the library module. An executable can only have 312 one main module, since a program has only a single entry-point. In this 313 case {{foo.scm}} is the main module, because it doesn't have a 314 {{unit}} declaration: 315 316 <enscript highlight=scheme> 317 ;;; foo.scm 318 319 ; The declaration marks this source file as dependant on the symbols provided 320 ; by the bar unit: 321 (declare (uses bar)) 322 323 (write (fac 10)) (newline) 324 </enscript> 325 326 {{bar.scm}} will be our library: 327 328 <enscript highlight=scheme> 329 ;;; bar.scm 330 331 ; The declaration marks this source file as the bar unit. The names of the 332 ; units and your files don't need to match. 333 (declare (unit bar)) 334 335 (define (fac n) 336 (if (zero? n) 337 1 338 (* n (fac (- n 1))) ) ) 339 </enscript> 340 341 ===== Compiling and running your program 342 343 You should compile your two files with the following commands: 344 345 % csc -c bar.scm 346 % csc -c foo.scm 347 348 That should produce two files, {{bar.o}} and {{foo.o}}. 349 They contain the code from your source files in compiled form. 350 351 To link your compiled files use the following command: 352 353 % csc foo.o bar.o -o foo 354 355 This should produce the {{foo}} executable, which you can run just as in the previous example. 356 At this point you can also erase the {{*.o}} files. 357 358 You could avoid one step and link the two files just as {{foo.scm}} is compiled: 359 360 % csc -c bar.scm 361 % csc foo.scm bar.o -o foo 362 363 Note that if you want to distribute your program, you might want it to 364 follow the GNU Coding Standards. One relatively easy way to achieve 365 this is to use Autoconf and Automake, two tools made for this specific 366 purpose. 244 an argument is ignored. So {{-:oh64m}} is OK, but {{-:h64mo}} will not 245 disable stack overflow checks. 367 246 368 247 === Extending the compiler … … 374 253 {{user-preprocessor-pass}}, {{user-pass}} and {{user-post-analysis-pass}} 375 254 can be set to procedures that are called to perform certain compilation 376 passes instead of the usual processing (for more information about 377 parameters see [[Supported language]]). 255 passes in addition to the usual processing. 378 256 379 257 These parameters are provided by the {{(chicken compiler user-pass)}} … … 404 282 seen by {{user-preprocessor-pass}}, but are seen by {{user-pass}}. 405 283 406 === Distributing compiled C files407 408 It is relatively easy to create distributions of Scheme projects that409 have been compiled to C. The runtime system of CHICKEN consists of only410 two handcoded C files ({{runtime.c}} and {{chicken.h}}), plus the files411 {{chicken-config.h}} and {{buildtag.h}}, which are generated by the412 build process. All other modules of the runtime system and the extension413 libraries are just compiled Scheme code. The following example shows a414 minimal application, which should run without changes on most operating415 systems, like Windows, Linux or FreeBSD (note however that static416 binaries are not supported on Mac OS X).417 418 Take the following "Hello World" program:419 420 <enscript highlight=scheme>421 ; hello.scm422 423 (print "Hello, world!")424 </enscript>425 426 % csc -t hello.scm -optimize-level 3 -output-file hello.c427 428 Compiled to C, we get {{hello.c}}. We need the files {{chicken.h}},429 {{chicken-config.h}}, {{buildtag.h}} and {{runtime.c}}, which contain430 the basic runtime system, plus the library files {{build-version.c}},431 {{chicken-syntax.c}}, {{eval.c}}, {{expand.c}}, {{internal.c}},432 {{library.c}} and {{modules.c}}, which contain the same functionality as433 the library that is linked into plain CHICKEN-compiled applications:434 435 % cd /tmp436 % echo '(print "Hello World.")' > hello.scm437 % csc -t hello.scm438 % cp $CHICKEN_BUILD/build-version.c .439 % cp $CHICKEN_BUILD/chicken-syntax.c .440 % cp $CHICKEN_BUILD/eval.c .441 % cp $CHICKEN_BUILD/expand.c .442 % cp $CHICKEN_BUILD/internal.c .443 % cp $CHICKEN_BUILD/library.c .444 % cp $CHICKEN_BUILD/modules.c .445 % cp $CHICKEN_BUILD/runtime.c .446 % cp $CHICKEN_BUILD/chicken.h .447 % cp $CHICKEN_BUILD/chicken-config.h .448 % cp $CHICKEN_BUILD/buildtag.h .449 % gcc -static -Os -fomit-frame-pointer -DHAVE_CHICKEN_CONFIG_H hello.c \450 build-version.c eval.c expand.c internal.c library.c modules.c runtime.c \451 -o hello -lm452 453 Once we have all the files together, we can create a tarball:454 455 % tar cf hello.tar hello.c build-version.c chicken-syntax.c eval.c \456 expand.c internal.c library.c modules.c runtime.c chicken.h \457 chicken-config.h buildtag.h458 % gzip hello.tar459 460 This is naturally rather simplistic. Things like enabling dynamic461 loading and selecting supported features of the host system would need462 more configuration- and build-time support. All this can be addressed463 using more elaborate build-scripts, makefiles or by using464 autoconf/automake.465 466 The {{chicken-config.h}} file may contain incorrect settings for your467 deployment target. Especially when the architecture is different. In468 that case you will have to adjust the values as needed.469 470 Note that the size of the application can still be reduced by removing471 any of the C files besides {{build-version.c}}, {{library.c}}, and472 {{runtime.c}}, and compiling {{hello.scm}} with the {{-explicit-use}}473 option.474 475 For more information, study the CHICKEN source code and/or ask on the CHICKEN476 mailing list.477 478 284 --- 479 285 Previous: [[Using the interpreter]] -
wiki/man/5/Using the interpreter
r35525 r35528 27 27 The parameter {{command-line-arguments}} is set to a list of the 28 28 parameters that were passed to the Scheme script. Scripts can be compiled 29 to standalone executables (don't forget to declare used library units).29 to standalone executables. 30 30 31 31 CHICKEN supports writing shell scripts in Scheme for other platforms as well, … … 132 132 133 133 You can define your own toplevel commands using the {{toplevel-command}} 134 procedure :134 procedure (see [[Module (chicken csi)]]). 135 135 136 136 … … 189 189 === History access 190 190 191 The interpreter toplevel accepts the special object {{# [INDEX]}} which191 The interpreter toplevel accepts the special object {{#INDEX}} which 192 192 returns the result of entry number {{INDEX}} in the history list. If 193 193 the expression for that entry resulted in multiple values, the first … … 195 195 {{INDEX}} is given (and if a whitespace or closing paranthesis 196 196 character follows the {{#}}, then the result of the last expression is 197 returned. Note that the value returned is implicitly quoted. 198 199 === Auto-completion and edition 197 returned. Note that the value that {{#INDEX}} stands for is an expression, 198 not a literal, and so is implicitly quoted, so 199 200 #;1> 123 201 123 202 #;2> '(1 2 #) 203 204 will not return the result you expected. 205 206 === Auto-completion and editing 200 207 201 208 On platforms that support it, it is possible to get auto-completion of … … 241 248 ; -h -help : Write a summary of the available command line options to standard output and exit. 242 249 243 ; -I -include-path PATHNAME : Specifies an alternative search-path for files included via the {{include}} special form. This option may be given multiple times. If the environment variable {{CHICKEN_INCLUDE_PATH}} is set, it should contain a list of alternative include pathnames separated by {{ ;}}.250 ; -I -include-path PATHNAME : Specifies an alternative search-path for files included via the {{include}} special form. This option may be given multiple times. If the environment variable {{CHICKEN_INCLUDE_PATH}} is set, it should contain a list of alternative include pathnames separated by {{:}} (UNIX) or {{;}} (Windows). 244 251 245 252 ; -K -keyword-style STYLE : Enables alternative keyword syntax, where {{STYLE}} may be either {{prefix}} (as in Common Lisp) or {{suffix}} (as in DSSSL). Any other value is ignored. … … 255 262 ; -q -quiet : Do not print a startup message. Also disables generation of call-trace information for interpreted code. 256 263 257 ; -r5rs-syntax : Disables the CHICKEN extensions to R5RS syntax. Does not disable [[Non-standard read syntax|non-standard read syntax]].264 ; -r5rs-syntax : Disables the CHICKEN extensions to R5RS syntax. Does not disable non-standard read syntax. 258 265 259 266 ; -s -script PATHNAME : This is equivalent to {{-batch -quiet -no-init PATHNAME}}. Arguments following {{PATHNAME}} are available by using {{command-line-arguments}} and are not processed as interpreter options. Extra options in the environment variable {{CSI_OPTIONS}} are ignored.
Note: See TracChangeset
for help on using the changeset viewer.