#include "spawn.h"
#endif
-// This is a bit messy because we define link ourself
#if !defined(__BORLANDC__) && !defined(_MSC_VER)
-
#include <unistd.h>
-
-#else
-// No unistd.h in Borland C++
-/*
-extern int access (const char *, int);
-#define X_OK 1
-*/
-
#endif
//REMOVE ME!!!
#define OPTION_NO_LOOP_IND "--noinduction"
#define OPTION_LESS_PEDANTIC "--lesspedantic"
#define OPTION_NO_GCSE "--nogcse"
-#define OPTION_SHORT_IS_CHAR "--short-is-char"
+#define OPTION_SHORT_IS_8BITS "--short-is-8bits"
/** Table of all options supported by all ports.
This table provides:
{ 'S', NULL, &noAssemble, "Assemble only" },
{ 'W', NULL, NULL, "Pass through options to the assembler (a) or linker (l)" },
{ 'L', NULL, NULL, "Add the next field to the library search path" },
+ { 'l', NULL, NULL, "Include the given library in the link" },
{ 0, OPTION_LARGE_MODEL, NULL, "Far functions, far data" },
{ 0, OPTION_MEDIUM_MODEL, NULL, "Far functions, near data" },
{ 0, OPTION_SMALL_MODEL, NULL, "Small model (default)" },
{ 0, OPTION_NO_LOOP_IND, NULL, NULL },
{ 0, "--nojtbound", &optimize.noJTabBoundary, "Don't generate boundary check for jump tables" },
{ 0, "--noloopreverse", &optimize.noLoopReverse, "Disable the loop reverse optimisation" },
- { 0, "--regextend", &options.regExtend, NULL },
{ 'c', "--compile-only", &options.cc_only, "Compile only, do not assemble or link" },
{ 0, "--dumpraw", &options.dump_raw, "Dump the internal structure after the initial parse" },
{ 0, "--dumpgcse", &options.dump_gcse, NULL },
{ 0, "--nooverlay", &options.noOverlay, NULL },
{ 0, "--main-return", &options.mainreturn, "Issue a return after main()" },
{ 0, "--no-peep", &options.nopeep, "Disable the peephole assembly file optimisation" },
+ { 0, "--no-reg-params", &options.noRegParams, "On some ports, disable passing some parameters in registers" },
{ 0, "--peep-asm", &options.asmpeep, NULL },
{ 0, "--debug", &options.debug, "Enable debugging symbol output" },
- { 0, "--nodebug", &options.nodebug, "Disable debugging symbol output" },
{ 'v', OPTION_VERSION, NULL, "Display sdcc's version" },
{ 0, "--stack-after-data", &options.stackOnData, NULL },
{ 'E', "--preprocessonly", &preProcOnly, "Preprocess only, do not compile" },
{ 0, "--nostdinc", &options.nostdinc, NULL },
{ 0, "--verbose", &options.verbose, "Trace calls to the preprocessor, assembler, and linker" },
{ 0, OPTION_LESS_PEDANTIC, NULL, "Disable some of the more pedantic warnings" },
- { 0, "--short-is-int", &options.shortisint, "Make short the same size as int" },
- { 0, OPTION_SHORT_IS_CHAR, NULL, "Make short the same size as char (default)" }
+ { 0, OPTION_SHORT_IS_8BITS, NULL, "Make short 8bits (for old times sake)" }
};
/** Table of all unsupported options and help text to display when one
{
if (_ports[i]->magic != PORT_MAGIC)
{
- printf ("Error: port %s is incomplete.\n", _ports[i]->target);
- wassert (0);
+ wassertl (0, "Port definition structure is incomplete");
}
}
}
);
}
-/*
- "\t-m<proc> - Target processor <proc>. Default %s\n"
- "\t Try --version for supported values of <proc>\n"
- "\t--model-large - Large Model\n"
- "\t--model-small - Small Model (default)\n"
- "\t--stack-auto - Stack automatic variables\n"
- "\t--xstack - Use external stack\n"
- "\t--xram-loc <nnnn> - External Ram start location\n"
- "\t--xstack-loc <nnnn> - Xternal Stack Location\n"
- "\t--code-loc <nnnn> - Code Segment Location\n"
- "\t--stack-loc <nnnn> - Stack pointer initial value\n"
- "\t--data-loc <nnnn> - Direct data start location\n"
- "\t--idata-loc <nnnn> - Indirect data start location\n"
- "\t--iram-size <nnnn> - Internal Ram size\n"
- "\t--nojtbound - Don't generate boundary check for jump tables\n"
- "\t--generic - All unqualified ptrs converted to '_generic'\n"
- "PreProcessor Options :-\n"
- "\t-Dmacro - Define Macro\n"
- "\t-Ipath - Include \"*.h\" path\n"
- "Note: this is NOT a complete list of options see docs for details\n",
-*/
/*-----------------------------------------------------------------*/
/* printUsage - prints command line syntax */
/*-----------------------------------------------------------------*/
options.nostdlib = 0;
options.nostdinc = 0;
options.verbose = 0;
- options.shortisint = 0;
+ options.shortis8bits = 1;
options.stack10bit=0;
then for input of '--optxyz' or '--opt xyz' returns xyz.
*/
static char *
-getStringArg(const char *szStart, char **argv, int *pi)
+getStringArg(const char *szStart, char **argv, int *pi, int argc)
{
- if (argv[*pi][strlen(szStart)]) {
- return &argv[*pi][strlen(szStart)];
+ if (argv[*pi][strlen(szStart)])
+ {
+ return &argv[*pi][strlen(szStart)];
}
- else {
- return argv[++(*pi)];
+ else
+ {
+ ++(*pi);
+ if (*pi >= argc)
+ {
+ werror (E_ARGUMENT_MISSING, szStart);
+ /* Die here rather than checking for errors later. */
+ exit(-1);
+ }
+ else
+ {
+ return argv[++(*pi)];
+ }
}
}
getStringArg.
*/
static int
-getIntArg(const char *szStart, char **argv, int *pi)
+getIntArg(const char *szStart, char **argv, int *pi, int argc)
{
- return (int)floatFromVal(constVal(getStringArg(szStart, argv, pi)));
+ return (int)floatFromVal(constVal(getStringArg(szStart, argv, pi, argc)));
}
static bool
if (strcmp (argv[i], OPTION_PEEP_FILE) == 0)
{
- options.peep_file = getStringArg(OPTION_PEEP_FILE, argv, &i);
+ options.peep_file = getStringArg(OPTION_PEEP_FILE, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_LIB_PATH) == 0)
{
- libPaths[nlibPaths++] = getStringArg(OPTION_LIB_PATH, argv, &i);
+ libPaths[nlibPaths++] = getStringArg(OPTION_LIB_PATH, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_CALLEE_SAVES) == 0)
{
- parseWithComma (options.calleeSaves, getStringArg(OPTION_CALLEE_SAVES, argv, &i));
+ parseWithComma (options.calleeSaves, getStringArg(OPTION_CALLEE_SAVES, argv, &i, argc));
continue;
}
if (strcmp (argv[i], OPTION_XSTACK_LOC) == 0)
{
- options.xstack_loc = getIntArg(OPTION_XSTACK_LOC, argv, &i);
+ options.xstack_loc = getIntArg(OPTION_XSTACK_LOC, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_STACK_LOC) == 0)
{
- options.stack_loc = getIntArg(OPTION_STACK_LOC, argv, &i);
+ options.stack_loc = getIntArg(OPTION_STACK_LOC, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_XRAM_LOC) == 0)
{
- options.xdata_loc = getIntArg(OPTION_XRAM_LOC, argv, &i);
+ options.xdata_loc = getIntArg(OPTION_XRAM_LOC, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_IRAM_SIZE) == 0)
{
- options.iram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i);
+ options.iram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_DATA_LOC) == 0)
{
- options.data_loc = getIntArg(OPTION_DATA_LOC, argv, &i);
+ options.data_loc = getIntArg(OPTION_DATA_LOC, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_IDATA_LOC) == 0)
{
- options.idata_loc = getIntArg(OPTION_IDATA_LOC, argv, &i);
+ options.idata_loc = getIntArg(OPTION_IDATA_LOC, argv, &i, argc);
continue;
}
if (strcmp (argv[i], OPTION_CODE_LOC) == 0)
{
- options.code_loc = getIntArg(OPTION_CODE_LOC, argv, &i);
+ options.code_loc = getIntArg(OPTION_CODE_LOC, argv, &i, argc);
continue;
}
}
if (strcmp (argv[i], OPTION_LESS_PEDANTIC) == 0)
- {
- setErrorLogLevel(ERROR_LEVEL_WARNING);
- continue;
- }
-
- if (strcmp (&argv[i][1], OPTION_SHORT_IS_CHAR) == 0) {
- options.shortisint=0;
- continue;
- }
+ {
+ setErrorLogLevel(ERROR_LEVEL_WARNING);
+ continue;
+ }
+
+ if (strcmp (&argv[i][1], OPTION_SHORT_IS_8BITS) == 0)
+ {
+ options.shortis8bits=1;
+ continue;
+ }
if (!port->parseOption (&argc, argv, &i))
{
break;
case 'L':
- libPaths[nlibPaths++] = getStringArg("-L", argv, &i);
+ libPaths[nlibPaths++] = getStringArg("-L", argv, &i, argc);
+ break;
+
+ case 'l':
+ libFiles[nlibFiles++] = getStringArg("-l", argv, &i, argc);
break;
case 'W':
/* linker options */
if (argv[i][2] == 'l')
{
- parseWithComma(linkOptions, getStringArg("-Wl", argv, &i));
+ parseWithComma(linkOptions, getStringArg("-Wl", argv, &i, argc));
}
else
{
/* assembler options */
if (argv[i][2] == 'a')
{
- parseWithComma ((char **) asmOptions, getStringArg("-Wa", argv, &i));
+ parseWithComma ((char **) asmOptions, getStringArg("-Wa", argv, &i, argc));
}
else
{
options.xstack_loc = options.xdata_loc;
/* if debug option is set the open the cdbFile */
- if (!options.nodebug && srcFileName)
+ if (options.debug && srcFileName)
{
sprintf (scratchFileName, "%s.cdb", srcFileName);
if ((cdbFile = fopen (scratchFileName, "w")) == NULL)
if (options.iram_size)
fprintf (lnkfile, "-a 0x%04x\n", options.iram_size);
- /*if (options.debug) */
- fprintf (lnkfile, "-z\n");
+ if (options.debug)
+ fprintf (lnkfile, "-z\n");
#define WRITE_SEG_LOC(N, L) \
segName = strdup(N); \
{
_validatePorts ();
- argc--;
- while (argc)
+ while (argc--)
{
if (!strncmp (*argv, "-m", 2))
{
return;
}
argv++;
- argc--;
}
/* Use the first in the list */
port = _ports[0];
// EndFix
return 1;
}
- if (!options.c1mode)
+ if (!options.c1mode && !noAssemble)
{
if (options.verbose)
printf ("sdcc: Calling assembler...\n");