Commit Graph

711 Commits

Author SHA1 Message Date
Jonas Maebe
a051b8d225 - remmoved doregister parameter from t*sym constructors, as the registration
is handled automatically nowadays

git-svn-id: trunk@42998 -
2019-09-14 17:30:45 +00:00
svenbarth
ced3885dbb * generate construction function for the attributes used in a unit using a more straight forward approach
ToDo: "collect" attributes of same type and same argument list and generate constructor only once for them

git-svn-id: trunk@42394 -
2019-07-12 22:07:20 +00:00
svenbarth
e296b26e9e - remove unit info and related code again as that will be handled similar, but differently with dynamic packages
git-svn-id: trunk@42369 -
2019-07-12 22:05:47 +00:00
svenbarth
b2932393df Reintegration of Custom Attributes branch by Joost van der Sluis with patches reworked by Svetozar Belic [patch 1/3]
Implemented attributes for class types and properties (based on work by Joost van der Sluis). Added TCustomAttribute - a base class for attributes. Added TUnitInfo record to RTTI. It contains the unit name and unit options (for now only a flag which specifies if the unit contains attributes). Added several tests for attributes.

git-svn-id: trunk@42356 -
2019-07-12 22:04:48 +00:00
pierre
243c967967 Commit of new debug feature implemented by J. Gareth Moreton
Allows compilation of compiler using -dDEBUG_NODE_XML
  which will generate a NAME-node-dump.xml file for each 
  unit, program or library compiled,
  containing a XML description of the nodes handled during
  compilation of the unit, program or library.

git-svn-id: trunk@42271 -
2019-06-22 14:08:47 +00:00
Jonas Maebe
0cd0e1614b * synchronised with trunk till r42105
git-svn-id: branches/debug_eh@42106 -
2019-05-19 19:24:25 +00:00
Jonas Maebe
aad87820e6 * abstracted registration of library init/fini routines (to be able to add
LLVM support)

git-svn-id: trunk@42104 -
2019-05-19 19:20:47 +00:00
Jonas Maebe
9e9a982bfe * synchronised with trunk till r42095
git-svn-id: branches/debug_eh@42096 -
2019-05-18 18:43:51 +00:00
Jonas Maebe
8ec3cd6390 * append rather than insert the alias symbols for the program/procedure
initialisation/finalisation routines
   o this ensures the procdef's mangled name and its first symbol match,
     which is required for Darwin when generating debug information and
     using ".set" directives to define alias symbols, because a symbol
     defined via ".set" cannot be used in a data relocations (and the DWARF
     debug generator uses the default mangled name, which used to correspond
     to the alias symbol due to the "insert" instead of "append")

git-svn-id: trunk@42094 -
2019-05-18 18:41:33 +00:00
Jonas Maebe
fc60ec2ea4 + support for LLVM LTO: compile units with -CLflto -> when compiling a main
program/library also with -Clflto, all units compiled with that option
    will be linked using their bitcode files and LTO
   o compiling with -CLflto will compile all units twice: once for normal
     (static or smart) linking, and once for LTO. So the result can be
     used both with and without LTO.

git-svn-id: branches/debug_eh@41910 -
2019-04-20 18:56:11 +00:00
Jonas Maebe
0b61b5d4cf * added extra header to ppu inside a subsection, so we won't run into
trouble when the ppu version hits 255
  * also moved several ppu flags to a set inside that section

git-svn-id: trunk@41846 -
2019-04-06 21:28:43 +00:00
Jonas Maebe
91d5457b38 * moved around/replaced the following procedures to stop nflw from depending
on pdecsub (node units should not depend on parser units):
   o maybe_add_public_default_java_constructor()
   o handle_calling_convention()
   o create_finalizer_procdef() (replaced with create_outline_procdef())
   o insert_record_hidden_paras()
   o handle_calling_convention()
   o proc_add_definition()
   o build_parentfpstruct()
   o maybe_guarantee_record_typesym()
   o get_first_proc_str()
  * factored out the creation of a procinfo for a nested procdef based on a
    subnodetree of the current procdef into tprocinfo.create_for_outlining()

git-svn-id: trunk@40773 -
2019-01-05 16:26:33 +00:00
Jonas Maebe
28df55fe08 * moved handle_calling_convention() to pparautl
git-svn-id: trunk@40772 -
2019-01-05 16:26:29 +00:00
marco
dd52e79089 * two comment spelling fixes. Mantis #34092 & #34097
git-svn-id: trunk@39593 -
2018-08-08 08:39:20 +00:00
svenbarth
35bddf6fb1 * correctly update the (now unregistered) unit symbol if the unit was found with the help of a default namespace
(this is needed to trigger the correct creation of the namespace symbols)

git-svn-id: trunk@38917 -
2018-05-05 17:18:42 +00:00
svenbarth
c0dcb505e2 * use the module's filename instead of the passed in name (we assume all units added that way don't use the
ability to have a different module name to their filename)

git-svn-id: trunk@38912 -
2018-05-05 17:18:29 +00:00
svenbarth
e59e9e2a0a * extend tunitsym to be created as registered or not (for now all are created as registered)
git-svn-id: trunk@38911 -
2018-05-05 17:18:26 +00:00
florian
8eb885de91 * better error message if a unit is not found
git-svn-id: trunk@37868 -
2017-12-29 17:27:44 +00:00
pierre
5780c608be Also generate FPC_HAS_FEATURE_XXX macros for programs, libraries and packages
git-svn-id: trunk@37732 -
2017-12-14 22:53:32 +00:00
florian
b41cb26727 + write selected features in ppu of the system unit and load them further on
* ppu version update
* -Sf might be used only during system unit compilation
* loadsystemunit factored out so the system unit can be loaded earlier than other units to get features set

git-svn-id: trunk@37708 -
2017-12-10 16:32:56 +00:00
pierre
4c3d8d422a Add _GLOBAL_OFFSET_TABLE_ for sparc64 if -Cg is used
git-svn-id: trunk@36743 -
2017-07-18 12:49:26 +00:00
svenbarth
c90fbe1bf0 * fix for Mantis #31795: append a $ to internal functions init, finalize, init_implicit and finalize_implicit as their section names otherwise look the same as those of user declared functions with the same name
+ added test

git-svn-id: trunk@36194 -
2017-05-12 13:32:37 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
svenbarth
cc42bb8a7a * generate the package stub for all Windows and NativeNT targets
git-svn-id: trunk@35373 -
2017-01-29 22:39:34 +00:00
svenbarth
48bddbbc43 * use new potype_pkgstub instead of gen_fpc_dummy() as the former works on all platforms that needs it
With this dynamic packages are starting to work on x86_64-win64

git-svn-id: trunk@35372 -
2017-01-29 22:39:06 +00:00
svenbarth
1a6a8b7c9f + introduce a new potype for the main stub of a package library (which on Windows is simply a DLLMain returning True)
git-svn-id: trunk@35371 -
2017-01-29 22:37:40 +00:00
Jonas Maebe
048666a25c * when freeing a procdef that hasn't been registered for writing to the ppu
at the end of compiling a unit, also remove it from its owning procsym
    in case the procsym does get written to the ppu (possible because you
    can have extra overloads in the implementation) (mantis #25283)
   o also fixes webtbf/tw4103 on the platforms where this still failed
     (on the platforms where it worked, it worked by accedent since the
      compiler was accessing memory of a freed procdef)

git-svn-id: trunk@35309 -
2017-01-15 17:41:27 +00:00
florian
42cde51805 * ignore warnings caused by boolean expression simplification
git-svn-id: trunk@35231 -
2017-01-04 16:33:31 +00:00
svenbarth
246de84ef3 * ensure that a finalization section is parsed before the generation of specializations as otherwise specializations in such sections would result in unresolved forward declarations
git-svn-id: trunk@34582 -
2016-09-30 15:41:35 +00:00
svenbarth
da5bc92ae0 * pmodules.finish_unit: fix condition that would lead to no implicit initialization code being generated if no explicit one is available, but an implicit one would be required
git-svn-id: trunk@34581 -
2016-09-30 15:11:16 +00:00
pierre
4d09dfca95 Remember usage of checkpointer (-gc) option:
Use new cs_checkpointer_called moduleswitches set element.
     Use new uf_checkpointer_called PPU flag (reusing obsolete uf_local_browser flag value)
     Emit warning if compiled library/program has any code using checkpointer.
  
 * ppu.pas: New constant: uf_checkpointer_called
 * globtype.pas: New constant: cs_checkpointer_called
 * fppu.pas: Set uf_checkpointer_called flag if cs_checkpointer_called is set in current_settings.module_switches
 * i8086/n8086mem.pas: Include cs_checkpointer_called in current_settings.moduleswitches
 *  ncgmem.pas: Likewise.
 * msg/errore.msg: Add new message saying that -gc and -Ur options are incompatible
   Add description to -gc option, saying it is experimental.
   Add warning at link time for program/library if checkpointer is used in any unit or main code.
 * options.pas: if -gc and -Ur options are used, never enable checkpointer code,
   instead output a warning that release is incompatible with -gc option.
 * pmodules.pas: proc_program: Check all modules for uf_checkpointer_called flag,
   emit a warning if checkpointer is used.
 * utils/ppuutils/ppudump.pp: Add code for uf_codepointer_called option.

git-svn-id: trunk@34567 -
2016-09-27 14:46:09 +00:00
pierre
3a9f2f55f4 -gc or {$CHECKPOINTER ON} requires heaptrc unit loading even for units
git-svn-id: trunk@34261 -
2016-08-10 09:44:01 +00:00
svenbarth
296b7dbaf5 * explicitely load the system unit if we have at least one required package (as one of those *must* contain the system unit); but don't add it to the used units of the package module as otherwise we'd detect the package to contain the system unit as well
git-svn-id: trunk@34254 -
2016-08-05 14:45:40 +00:00
svenbarth
839d82d9c6 - remove generation of the _FPCDummy symbol; for now this leads to more trouble than it has uses (namely none so far)
git-svn-id: trunk@34230 -
2016-07-29 16:06:35 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
Jonas Maebe
3c446c8605 * fixed crash when compiling libraries on non-Darwin after r34134
git-svn-id: trunk@34140 -
2016-07-16 14:13:33 +00:00
Jonas Maebe
88a736c95a * moved the code generated for library init/fini to the al_pure_assembler
list, so that the assembler directives generated for Darwin are emitted
    correctly for LLVM
   o extracted the library init code generation from hlcgobj to pmodules so
     we don't add things to another list than what's passed to
     gen_proc_symbol_end(), and so it's done where we generate the init
     routine for libraries (rather then checking for every routine whether
     it's the init routine for a library)
   o removed the llvm-specific gen_proc_symbol_end() because the regular one
     now does the same

git-svn-id: trunk@34134 -
2016-07-15 14:34:11 +00:00
svenbarth
f27ce0b159 Rework the way the method bodies for specializations are generated: instead of walking the global and local symboltable all pending specializations are kept in a list of the current module which is (for now) walked at the end of a unit/program to generate the method bodies as before.
fmodule.pas, tmodule:
  + new list pendingspecializations which keeps track of all pending specializations of the current module
psub.pas:
  * move generate_specialization_procs and related routines to pgenutil
  + new procedure read_proc_body to read a routine's body, cause generate_specialization_procs needs it (unlike the already existing overload in the implementation section, this one can only handle bodies of non-nested routines) 
pgenutil.pas:
  * generate_specialization_phase2: add the newly specialized generic to the current module's pending specializations
  * generate_specialization_procs: reworked so that it uses the new pendingspecializations field instead of walking the global and local symboltable of the current unit
pmodules.pas:
  + add pgenutil to uses due to the moved generate_specialization_procs

+ added test

git-svn-id: trunk@33826 -
2016-05-26 18:56:16 +00:00
svenbarth
1824a945cf Merged revision(s) 32515, 32573, 32575, 32579 from branches/svenbarth/packages:
Report a warning if a unit is used from an indirectly used package. We are doing this only for the units used in contained units though as in the "contains" section there can't be such units anyway (and just checking all loaded units would lead to false positives).

pkgutil.pas:
  + new procedure check_for_indirect_package_usages() which walks a TLinkedList of used units and warns on every unit that is from an indirectly imported package
pmodules.pas, proc_package:
  * when checking all loaded units whether they are from a package or not also check for indirect package usages using the new procedure

........
pkgutil.pas, exportprocsym:
  * use a temporary variable for the procdef
  * restructure the if-expression a bit to make it better readable

........
pmodules.pas, finish_unit:
  * also release the generated proc symbol if the init function isn't needed

........
pkgutil.pas, add_package_libs:
  * fix exit condition (on Linux it probably worked by accident :/ )
........

git-svn-id: trunk@33518 -
2016-04-15 14:47:51 +00:00
svenbarth
e8ede4c3e2 Merged revision(s) 32508-32510, 32512 from branches/svenbarth/packages:
Keep track whether a package was added directly through a requires section (or the command line) or indirectly.

fpkg.pas, tpackageentry:
  + new field "direct"
pkgutil.pas:
  + add_package: new parameter "direct" which sets the "direct" field of the new package entry
options.pas:
  * TOption.interpret_option & read_arguments: adjust call to add_package()
pmodules.pas:
  * proc_package: adjust call to add_package()

........
Also load all packages that are required by packages, but that are not part of the directly used packages.

pkgutil.pas, load_packages:
  * check the list of required packages for packages that are not yet part of the package list and add these as indirect packages
  * establish the links to loaded packages in the required packages once all packages were loaded

........
fpcp.pas, tpcppackage:
  + new method add_required_package() to add a required package while ignoring duplicates

........
pmodules.pas, proc_package:
  * add all packages of loaded units as required packages

........

git-svn-id: trunk@33517 -
2016-04-15 14:42:24 +00:00
svenbarth
3e70ac05c2 Merged revision(s) 32450-32451, 32455, 32457-32458, 32460-32462, 32477, 32480 from branches/svenbarth/packages:
cclasses.pas, TCmdStrList:
  * if doubles are not allowed then do case sensitive checks instead of insensitive ones

........
Correctly handle export/import generation depending on whether we're compiling for a system that needs indirect imports or not.

systems.pas:
  * replace systems_package_need_exports with systems_indirect_var_imports
pmodules.pas, proc_package:
  - remove check for systems_package_need_exports
pkgutil.pas:
  * insert_export, export_unit: export the direct or the indirect variable symbol depending on systems_indirect_var_imports

........
ncgrtti.pas, TRTTIWriter.write_extra_rttisyms:
  * enumdef_rtti_string2ordindex & enumdef_rtti_ord2stringindex: put the indirect suffix at the end of the symbol

........
pkgutil.pas, add_package_libs:
  * check for systems_indirect_var_imports instead of systems_package_needs_exports

........
expunix.pas, texportlibunix:
  * generatelib: check all procdefs whether they have the alias and not only the first one

........
pkgutil.pas:
  * insert_export: directly report the symbol type instead of its ordinal to ease finding of problems

........
pkgutil.pas, export_procsym:
  * restructure if for better readability
  + also check the procdef for po_has_public_name

........
Ensure that all implicitely imported units are indeed part of the package.

pmodules.pas, proc_package:
  * instead of checking the units loaded by the current module we need to check *all* units that are loaded for the package

........
Fix inclusion of PPUs that don't have a corresponding object file.

pkgutil.pas, RewritePPU:
  * don't abort if a unit does have the flag uf_no_link set
  * only abort if both uf_static_link and uf_no_link are not set

........
Generate an error if a unit listed as in "contains" is part of a directly or indirectly required package.

pmodules.pas, proc_package:
  * walk all units and check whether it had been loaded from a package, but is also part of the units of the current module; if so then generate an error

........

git-svn-id: trunk@33516 -
2016-04-15 14:23:55 +00:00
svenbarth
7d8d0340b9 Merged revision(s) 31988, 31991-31993, 32136, 32308-32309, 32312, 32318 from branches/svenbarth/packages:
Correctly parse the directives DenyPackageUnit and WeakPackageUnit

ppu.pas:
  + add flags uf_packagedeny and uf_packageweak
scandir.pas:
  + new procedure do_moduleflagswitch() which parses a ON/OFF/+/- argument and sets or clears a flag in the current module
  + new procedure dir_denypackageunit which handles DenyPackageUnit
  * implement dir_weakpackageunit (and move to the correct location ;) )
  * InitScannerDirectives: add dir_denypackageunit handler
........
Respect DenyPackageUnit flag.

pmodules.pas, proc_package:
  * check all contained units that are not already part of a package for their uf_package_deny flag and report an error for each that has it set
........
Do not check whether all units are used as by definition all units of a package are considered as used.

pmodules.pas, proc_package:
  - remove call to current_module.allunitsused
........
Check whether a unit has been implicitely imported in a package. A unit is considered as implicitely imported if it is not part of a required package nor part of the units listed in the contains section. This note is useful (Delphi even provides a dialog in that case) as a package with implicitely imported units /might/ become incompatible with other packages (e.g. if another package includes that unit uses that package and includes that unit explicitely; of course that is the same as if both package included it explicitely, but with the hint one knows where to look).

pmodules.pas, proc_package:
  * while walking the loaded units also check whether any of them not contained in a package was part of the contained units which are the same as the current module's used units
........
Generate CRC for package files

pcp.pas, tpcpfile:
  + new field do_crc which controls CRC generation
  + override putdata() method to generate CRC when data is written
  * resetfile: enable do_crc by default
........fppu.pas, tppumodule:
  * loadfrompackage: mention if a unit is loaded from a package
........
fpkg.pas, tcontainedunit:
  + new fields offset and size for the PPU data stored inside the PCP
fpcp.pas, tpcppackage:
  * readcontainedunits & addunit: correctly initialize offset and size to 0
........
Store the modified PPU files directly inside the PCP and thus get finally rid of the .ppl.ppu files.

entfile.pas:
  + new entry type ibpputable
pkgutil.pas:
  * adjust RewritePPU to work on a stream as output instead of a filename
fpcp.pas, tpcppackage:
  + new method writepputable() which writes the offsets and sizes of all contained units (not part of CRC!)
  + new method writeppudata() which rewrites all contained PPUs directly into the PCP after the ibend entry (Note: the data is written 16 Byte aligned to ease viewing of the PCP and its contained PPUs in a hex editor)
  + new method readpputable() which reads the offsets and sizes of all contained units
  + new method getmodulestream() which returns a substream for a contained module
  * loadpcp: also call readpputable()
  * writepcp: first write an empty pputable, then finish writing all data that requires the put*/write* methods of the pcpfile, then use writeppudata() to write all PPUs and finally write the correct pputable at the original location
fppu.pas, tppumodule:
  * loadfrompackage: don't read the PPU from a file if it is contained in a package, but using the new tpcppackage.getmodulestream() and tppumodule.openppustream() methods
pmodules.pas, proc_package:
  * don't rewrite the PPUs here
pcp.pas:
  * increase CurrentPCPVersion
........
Fix cycling

........

git-svn-id: trunk@33514 -
2016-04-15 13:39:41 +00:00
svenbarth
c5bdc11cb2 Merged revision(s) 31924, 31934-31937 from branches/svenbarth/packages:
pmodules.pas, proc_package:
  * generate the dummy entry symbol only on Windows systems (ToDo for other systems that might need it)

........
options.pas:
  * TOption.interpret_option & read_arguments: use add_package() from pkgutils instead of addpackage() from fpkg
fpkg.pas:
  - remove no longer needed addpackage()

........
pkgutil.pas:
  + new procedure add_package_libs() to add all packages as libraries that are also linked against
pmodules.pas:
  * proc_package & proc_program: add all package libraries to the linker before creating the final binary

........
pkgutil.pas, add_package:
  * package names are case insensitive so add them in uppercase to correctly detect duplicates

........
Keep track of how many units are used from each required/requested package and only link those from which any units are used.

fpkg.pas, tpackageentry:
  + new field usedunits to count how many units of the package are used
pkgutil.pas:
  + new procedure add_package_unit_ref() to increase the amount of used units for the given package
pmodules.pas:
  * proc_package & proc_program: check which units of all loaded ones are provided by other packages

........

git-svn-id: trunk@33510 -
2016-04-14 21:35:47 +00:00
svenbarth
e2b1f70ac6 Local symbols and defs that are needed for packages need to be registered as well => register the symbols and defs for the init and finalize functions.
pmodules.pas:
  * create_main_proc: register the proc's symbol
ngenutil.pas, tnodeutils:
  * create_main_procdef: register the proc's def

git-svn-id: trunk@33507 -
2016-04-14 21:30:36 +00:00
svenbarth
f55123ce92 Merged revision(s) 28904-28905, 29038-29044 from branches/svenbarth/packages:
Don't try to export generic symbols.

pkgutil.pas:
  * exportabstractrecordsymproc: do not export generic type symbols or their nested symbols
........
Ensure that the correct name is used for the PCP file.

proc_package:
  * use current_module.modulename instead of module_name for the base filename of the PCP file
........
Add a possibility to track if a unit was loaded from a package.

fmodule.pas, tmodule:
  + new field "package" which is Nil if the unit is not (yet) part of a package or a reference to the package this unit was loaded from
fppu.pas, tppumodule:
  * loadfrompackage: set the "package" field of the module to the package it's loaded from.

........
Ensure that units loaded from a package are not recompiled if the source files should happen to be available.

fppu.pas, tppumodule:
  loadppu: set the state to ms_compiled instead of ms_load if the unit was loaded from a package (additionally close the PPU file as it's no longer needed)

........
Add support for reading/writing required packages from/to the PCP file

fpcp.pas, tpcppackage:
  + new methods writerequiredpackages and readrequiredpackages
  * loadpcp: use readrequiredpackages
  * savepcp: use writerequiredpackages
pcp.pas:
  * increase PCP version

........
When compiling a package, handle only those units that are not yet part of a package.

pmodules.pas, proc_package:
  * only export units that are part of the package
  * only add units to the package if they are really part of the package
  * don't rewrite the PPU if the unit is not part of the package
  * don't link the unit's files if it is not part of the package

........
Add support for parsing required packages.

pkgutil.pas:
  + new function add_package to add a package to the list of available packages with the possibility to check for duplicates
  * load_packages: also load all required packages
pmodules.pas, proc_package:
  * create the tpcppackage instance earlier (and use the module name as read from the source file as package name)
  * clear the list of packages in case the user passed any using -FPxxx
  * parse the "requires" section like a list of units and add each full identifier as a package to load
  * before parsing the "contains" section load all packages, so that all units can be correctly resolved

........
Correctly create import libraries for packages as well.

pkgutil.pas, createimportlibfromexternals:
  * instead of processing units without the uf_in_library flag, only process those that don't have a package reference set (thus becoming part of the program/library or the package)
  - remove unneeded "pkg" parameter
pmodules.pas:
  + proc_package: create the import library if the package requires other packages
  * proc_program: adjust call to createimportlibfromexternals

........
Ensure that the reference to the System unit is correctly set up for packages. Among other things this is needed to compile a package with the -gl option (though debug information doesn't work yet).

pmodules.pas:
  * convert AddUnit to a function and let it return the newly loaded module
  * proc_package: when parsing the contained units ensure that we correctly set up the System unit reference if we are to contain the System unit
  * proc_package: also set up the System unit reference once all units are loaded and this hasn't happened yet (because all contained units are already compiled)

........

git-svn-id: trunk@33502 -
2016-04-14 20:01:17 +00:00
svenbarth
9d1938a713 Partial merge of r28851 (aside the parts that requires the global assembler symbols)
Generate the import library for each used package.

pkgutil.pas:
  - remove function createimportlibfromexports
  + new function createimportlibfromexternals which uses the imported unit symbols of a unit to generate the correct import library for each used package used in a program or library
pmodules.pas, proc_program:
  * move the generation of the import library further down until all tables were generated of which entries might reside in a package
  * use createimportlibfromexternals to generate the import library for the program/library
-- Diese und die folgenden Zeilen werden ignoriert --

M    pmodules.pas
M    pkgutil.pas

git-svn-id: trunk@33493 -
2016-04-12 21:32:25 +00:00
svenbarth
f8e9b33f99 Merge first batch of package handling related revisions from the packages branch
Merged revision(s) 28796, 28837-28845, 28847-28850, 28852, 32135 from branches/svenbarth/packages:
Provide possibility to pass packages and search paths for packages as parameters.

fpkg.pas:
  + new unit which contains the base types related to package files (most importantly "tpackage")
globals.pas:
  + new variable "packagesearchpath" which contains all paths in which package files should be looked for
  + new variable "packagelist" which contains a list of all packages that should be used in a program or library
  * InitGlobals & DoneGlobals: initialize/finalize "packagesearchpath" accordingly ("packagelist" is handled in unit fpkg using a init/done-callback)
options.pas:
  + TOption: new fields "parapackagepath" and "parapackages" to keep track of package search paths and package files passed as parameters
  * TOption.interpret_option: use '-Fp' for package search paths and '-FP' for package files
  * read_arguments: apply the passed package search paths and packages to their respective containers
........
+ add a new unit which will contain basic functions related to handling packages
........
Move package related functions from pmodules to pkgutil.

pmodules.pas => pkgutil.pas:
  * createimportlibfromexports
  * varexport
  * procexport
  * insert_export
  * RewritePPU
........
* adjust indentation
........
Extract the code to export the symbols of a unit to its own function in pkgutil so that less functions need to be exported.

pmodules.pas, proc_package:
  * move code to export the symbols of a unit to new function export_unit
pkgutil.pas:
  + new function export_unit
  - remove exports of procexport, varexport and insert_export
........
Some small fixes for package parsing.

pmodules.pas, proc_package:
  * use orgpattern instead of pattern to build the module name (like is done in uses sections)
  * ignore duplicates when generating exports
  - no need to generate an import library for the package; that is done by the program/library that uses the package
........
+ new unit fpcp of which the class tpcppackage handles the reading and writing of package metadata from/to pcp files (equivalant to tppumodule).
........
+ add unit which contains representation of a PCP file (tpcpfile) like tppufile is for units.
........
Improve export generation.

pkgutil.pas:
  + new function exportprocsym to correctly export a procedure with all its aliases
  + new function exportabstractrecordsymproc to export the members of structured types 
  * insert_export: handle also namespacesym and propertsym (by ignoring them)
  * insert_export: correctly export classes, record and objects
  * insert_export: use new exportprocsym function to export a procsym
  * insert_export: only export public variables of a static symtable


........
+ add entry constants for the name of the package and the package file names, both used by a PCP file
........
* use messages to get rid of most writelns related to package loading
........
Add additional entry types for PCP files

entfile.pas:
  + new entries ibstartrequireds and ibendrequireds to store the list of required packages
  + new entries ibstartcontained and ibendcontained to store the list of contained units
  + new entries ibstartppus and ibendppus to store the list of contained PPU files
........
Generate the PCP file once the package file and the used units were compiled correctly.

pmodules.pas:
  * proc_package: generate the PCP file upon successful compilation
........
Add the possibility to load all packages supplied as parameters.

pkgutil.pas:
  + new function load_packages to load all packages supplied as parameters
pmodules.pas, proc_program:
  * use load_packages to load all packages before any unit is loaded
........
Add code which tries to load a unit from a package first and only then as usual.

fppu.pas, tppumodule:
  + new method loadfrompackage which searches all available packages for the unit and loads it from there if found
  * loadppu: first try to load the unit from a package if any are available
........
Don't link objects files of a unit that is provided by a package.

pmodules.pas, proc_program:
  * if a unit has uf_in_library set we must not include it in the units we link against
........

git-svn-id: trunk@33452 -
2016-04-08 15:40:27 +00:00
svenbarth
557f74cdbd (Note to self: always include the root of the working copy in the commit when dealing with merges -.-)
Merged revision(s) 28793, 28903, 31951 from branches/svenbarth/packages:
psub.pas, read_proc:
  * don't generate assembler symbols for compiler internal code
........
Ensure that unneeded initialization/finalization procedures don't leave assembler symbols.

ncgutil.pas:
  + new function release_proc_symbol which removes all assembler symbols of a procdef
pmodules.pas, proc_unit:
  * if the initialization or finalization procedure is empty also remove their assembler symbols so they are exported
........
Ensure that readonly sections that need relocations are indeed declared as such.
Thanks to Jonas for this.

ncgvmt.pas, TVMTWriter:
  * writeinterfaceids: use sec_rodata instead of sec_rodata_norel

........

git-svn-id: trunk@32982 -
2016-01-22 16:58:33 +00:00
svenbarth
9d5f98eaa3 Merged revision(s) 28690 from branches/svenbarth/packages:
Extract reading of the PPU/PCP version into tentryfile.

entfile.pas:
  + add new getversion method which uses the pointer returned by getheaderaddr to read the PPU/PCP version
ppu.pas:
  - remove GetPPUVersion method
fppu.pas, pmodules.pas, utils/ppufiles.pp, utils/ppumove.pp, utils/ppuutils/ppudump.pp
  * replace call to GetPPUVersion by call to getversion
........

git-svn-id: trunk@32980 -
2016-01-22 15:47:29 +00:00
svenbarth
e9d8fadb58 Merged revision(s) 28237 from branches/svenbarth/packages:
Add a new target flag which determines whether the target supports dynamic packages or not.

systems.pas:
  + new flag tf_supports_packages
pmodules.pas, proc_package:
  * error out when flag tf_supports_packages is not set for the current target
msg/errore.msg:
  + error message for when tf_supports_packages is missing and a package file is compiled
........

git-svn-id: trunk@32978 -
2016-01-22 15:35:41 +00:00
svenbarth
02e56f410d Merged revision(s) 28689 from branches/svenbarth/packages:
Extract functionality that is shared between the metadata files for units (PPU) and for packages (PCP) into a parent class called tentryfile

+ add new unit entfile which contains the new tentryfile class and related types and constants
* ppu.pas:
    - remove methods, fields, types and constants which were moved to entfile.pas
    * replace the parts of tppuheader shared with tentryheader by a field of type tentryheader
fppu.pas, pmodules.pas, utils/ppumove.pp, utils/ppuutils/ppudump.pp:
    + add entfile to uses
    * adjust access to common header fields
node.pas, symdef.pas, symsym.pas, symtable.pas, wpoinfo.pas, utils/ppufiles.pp:
    + add entfile to uses
........

git-svn-id: trunk@32976 -
2016-01-22 15:26:30 +00:00
svenbarth
3b71841a84 Merged revision(s) 28691, 31914 from branches/svenbarth/packages:
Convert export options from constants to a set and accordingly adjust all usage locations

git-svn-id: trunk@32945 -
2016-01-15 16:06:06 +00:00
Jonas Maebe
7a8079cfb4 * removed DLLsource global variable and replaced its uses with
current_module.islibrary

git-svn-id: trunk@32676 -
2015-12-17 15:23:05 +00:00
sergei
84c33631ef * Have the sysinit unit, if any, passed to the linker first (currently it is passed last). This is necessary to get the same linking order on targets with assembler startup and with Pascal startup. In particular, it allows to define global symbols like "data_start" in sysinit unit and expect that they will actually end up before other data in executable.
git-svn-id: trunk@32674 -
2015-12-17 11:57:19 +00:00
Jonas Maebe
ba92fdafcc * free the calleeside paraloc information after a unit has been compiled
git-svn-id: trunk@32519 -
2015-11-24 20:10:32 +00:00
svenbarth
0ac12f0eaf Extend tstaticvarsym (and by extension tabstractnormalvarsym) with the capability to create it as unregistered if needed.
git-svn-id: trunk@32373 -
2015-11-20 11:15:30 +00:00
florian
70b8789262 o basic extended pascal support:
+ automatically loaded helper unit
  * Makefiles adapted
  * mode switch
  * mode switches reorganized
+ TimeStamp support

git-svn-id: trunk@32330 -
2015-11-15 15:13:36 +00:00
Jonas Maebe
fa3b0ca312 * support marking defs created via the getreusable*() class methods as
"don't free even if not registered"; use for defs that may not be written
    to a ppu file, but that must nevertheless survive the compilation of the
    current module
  * mark all defs created for para locations as "don't free even if not
    registered", because we don't discard and recalculate all para locations
    after a module has been compiled (since that's not needed)
   o solves issues if the paralocations for a routine in the interface of
     unit A are calculated while the implementation of unit B gets
     compiled, and a new reusable type is allocated at that point which
     is not used anywhere else (after r32160)

git-svn-id: trunk@32235 -
2015-11-04 20:46:18 +00:00
pierre
f380b80b3e Also set cs_create_pic in init_settings so that units are compiled with this setting if tf_library_needs_pic is in target info flags
git-svn-id: trunk@32199 -
2015-10-30 13:37:03 +00:00
Jonas Maebe
7d5262ef78 * free unregistered elements of the localsymtable after a module has been
compiled

git-svn-id: trunk@32160 -
2015-10-26 19:56:09 +00:00
Jonas Maebe
192bb3e032 * free the implementation info for procdefs immediately after a module
has been compiled

git-svn-id: trunk@32042 -
2015-10-13 15:58:54 +00:00
Jonas Maebe
faf4a9cb38 * moved the generation of the "main" stub for libc-based platforms from
hlcgobj to pmodules/symcreat/ngenutil, so that it also works for llvm

git-svn-id: trunk@31658 -
2015-09-12 23:34:01 +00:00
Jonas Maebe
be2ec5be59 * write full/init rtti and VMTs separately instead of at the same time
o this allows us to write the VMTs earlier (before the synthetic method
     implementations are generated), which means we can create new synthetic
     methods while generating the VMTs (for interface trampolines)

git-svn-id: trunk@31635 -
2015-09-12 23:32:38 +00:00
svenbarth
84b9d9839c + extend tobjectdef with the possiblity to create it as unregistered
* for now all objectdefs are created as registered
Note: an additional parameter instead of an overload is used for tobjectdef.create as otherwise both constructors would need to be overridden in potential descendant CPU-specific classes...

git-svn-id: trunk@31592 -
2015-09-11 13:28:49 +00:00
svenbarth
d45c275ef3 + extend ttypesym with the possiblity to create it as unregistered
* for now all typesyms are created as registered
Note: an additional parameter instead of an overload is used for ttypesym.create as otherwise both constructors would need to be overridden in potential descendant CPU-specific classes...

git-svn-id: trunk@31591 -
2015-09-11 13:22:12 +00:00
Jonas Maebe
bc62795f15 * removed no longer used simplify_ppu global
git-svn-id: trunk@31445 -
2015-08-28 22:31:24 +00:00
Jonas Maebe
0d74e4f719 * changed paratargetdbg from a global variable into a field of toption
git-svn-id: trunk@31443 -
2015-08-28 22:31:17 +00:00
florian
7dd1d6aa77 o fixes handling of iso i/o parameters/program parameters:
* explicit reset is needed
  * variable must be declared again

git-svn-id: trunk@30757 -
2015-05-01 20:58:31 +00:00
Jonas Maebe
1941e64488 + added a hook to insert object-global information into the asmlists (will
be used to insert type definitions for llvm)

git-svn-id: trunk@30674 -
2015-04-19 21:37:43 +00:00
Jonas Maebe
39594adae1 * different, simpler fix for #27691 fixed in r30261; should fix the
internalerrors on some platforms after that revision

git-svn-id: trunk@30265 -
2015-03-20 14:23:28 +00:00
Jonas Maebe
ea3a306da8 * never say that an automatically added unit is unused (mantis #27691)
git-svn-id: trunk@30261 -
2015-03-19 17:48:57 +00:00
florian
91db2a1698 + report when compilation of a unit is stopped because it has been already compiled during the recursive search in uses clauses
git-svn-id: trunk@30001 -
2015-02-24 21:46:09 +00:00
florian
a5bef2a2b9 * prevent new definitions being added to a global unit symtable after compilation of the implementation part started
git-svn-id: trunk@29811 -
2015-02-23 22:10:46 +00:00
Jonas Maebe
146e3bcb9e * synchronised with trunk till r29513
git-svn-id: branches/blocks@29516 -
2015-01-21 23:28:34 +00:00
Jonas Maebe
e97f31541e - reverted partial commit of merge
git-svn-id: branches/blocks@29515 -
2015-01-21 23:24:37 +00:00
Jonas Maebe
a76bbf363d * synchronised with trunk r29513
git-svn-id: branches/blocks@29514 -
2015-01-21 23:18:29 +00:00
Tomas Hajny
3ee3542744 * boolean constant instead of IFDEFs for detection of microcontroller support
git-svn-id: trunk@29052 -
2014-11-10 12:34:59 +00:00
Jonas Maebe
bd09b88a5b + support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension)
o blocks are implemented as a variation of procedure variables
   o declaration of a block variable: "test: procedure(c: char) is block;"
     (C equivalent: (void)(^test)(char c) )
   o the compiler automatically converts procedures/functions whose address
     is passed to a block parameter or assigned to a block variable into
     a "block". This consists of
    1) generating a block descriptor (containing the size of the "block
       literal" (see below) and the signature of the invocation function
       encoded as an Objective-C selector)
    2) generating a wrapper function around the original funcion (with C
       calling convention), that has an extra first hidden parameter
       (marked as vo_is_parentfp in the compiler) whose type is a pointer
       to the describing "block literal"
    3) generating the "block literal", which contains a pointer to an
       external variable indicating whether this block captures context or
       not, some flags (see compiler/blockutl.get_block_literal_flags for
       info), a pointer to the wrapper function and a pointer to the
       descriptor. In the future, it will also contain captured variables.
   o right now, only global procedures/functions can be converted to blocks
     (because they don't require state capturing). The next steps are (Object
     Pascal) methods (not Objective-C methods, because Objective-C method
     procvars don't exist) and finally nested functions
   o on Mac OS X, the functionality will only work on Mac OS X 10.7 and later,
     because we have to use the so-called "ABI.2010.3.16" to ensure that
     our blocks aren't called as variadic functions by the runtime (which
     came out after the Mac OS X 10.6 release)
   o while the currently implemented functionality does not require any
     library support at all, there's no use enabling it on other platforms
     because unless it has been confirmed to work with a blocks runtime,
     there's no point in using blocks (they're just somewhat bulky procvars
     right now). Enabling it on other platforms (in combination with the
     GNUStep Objective-C run time), should simply be a matter of adding
     the right {$linklib xxx} statement to rtl/inc/blockrtl.pp file, adding
     that file to Makefile.fpc for that platform and adding that platform
     to the compiler/systems.systems_blocks_supported set

git-svn-id: branches/blocks@28232 -
2014-07-18 09:15:22 +00:00
sergei
3eec9996bc * Moved method check_hints from tmodule to tused_unit and modified it so warning messages are output with position info from associated unitsym. Resolves #25057.
git-svn-id: trunk@27795 -
2014-05-15 21:16:36 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
florian
b2b26f84cf * partially merged the mips-embedded branch of Michael Ring:
- startup code/controller units are not merged yet
  - assembler call does not pass the needed CPU type yet

git-svn-id: trunk@27188 -
2014-03-19 21:25:38 +00:00
Jonas Maebe
009c96a0bd * fixed setting up the global switch for main programs without a "program"
header on platforms not in systems_unit_program_exports

git-svn-id: trunk@26975 -
2014-03-06 18:41:03 +00:00
florian
68f1a51164 * set PIC defines earlier, resolve #25788
git-svn-id: trunk@26924 -
2014-03-02 15:35:08 +00:00
florian
fe7238bdf1 * avoid compiler warning about uninitialized variable
git-svn-id: trunk@26441 -
2014-01-12 21:21:56 +00:00
florian
15df4a4f80 + support iso pascal like program parameters in iso mode
git-svn-id: trunk@26437 -
2014-01-12 20:17:51 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
paul
2fa739f729 compiler: remove unneeded push/pop to symtablestack
git-svn-id: trunk@25518 -
2013-09-18 05:24:19 +00:00
paul
5aa919c2a8 compiler: have unit interface symtable in stack while parsing implementation uses list (fixes issue #10477)
git-svn-id: trunk@25505 -
2013-09-17 08:53:37 +00:00
paul
0d8ad2a932 compiler: don't treat TRUE and FALSE as keywords. They are predefined constants from this moment. This change is compatible with other pascal compilers. Fixes issue #0025030
git-svn-id: trunk@25497 -
2013-09-16 09:11:17 +00:00
paul
60c0de6c09 compiler: formatting
git-svn-id: trunk@25476 -
2013-09-13 02:24:47 +00:00
sergei
d11ec8ac47 - Reverted r25269 and commented out r25261. The former one is wrong because it changes unit initialization order. The latter one causes RTL build failures on some targets, needs testing and likely RTL/makefiles patching.
git-svn-id: trunk@25271 -
2013-08-16 15:17:25 +00:00
sergei
e1ddd914ac * Do not implicitly load Variants unit when compiling units. Doing so is mostly waste of time, and introduces unwanted build dependencies. It is enough to set uf_uses_variants flag for units, and examine these flags when compiling program/library. Resolves #24880.
git-svn-id: trunk@25269 -
2013-08-16 12:42:47 +00:00
florian
5e0585c0d0 + introduce tf_no_objectfiles_when_smartlinking so object file generation on i8086-msdos can be turned off
* object file generation on i8086-msdos can be turned off if smartlinking is enabled

git-svn-id: trunk@24396 -
2013-04-30 19:11:55 +00:00
sergei
d54d38b4ab * Moved all code responsible for writing VMTs and interface wrappers (nobj.TVMTWriter, ncgutil.gen_intf_wrappers, ptype.write_persistent_type_info) into a new unit ncgvmt.pas.
This improves compiling speed a bit (two iterations over symtables replaced by one, code generator is created once per unit rather than once per class).
In perspective it makes possible to reduce amount of generated smartlink sections and global labels.

git-svn-id: trunk@24269 -
2013-04-19 13:31:27 +00:00
florian
784641ec46 * delay parsing of the closing SEMICOLON of a uses clause till the
unit map is updated to avoid symbols not being found, resolves #8611

git-svn-id: trunk@23886 -
2013-03-17 11:06:04 +00:00
paul
5d74e0578a compiler: remove unused variables and unneeded assignments
git-svn-id: trunk@23467 -
2013-01-21 01:24:36 +00:00
Jeppe Johansen
8b17a358e4 Remove all traces of the interrupt vector table generation mechanism
Clean up cpuinfo tables
Fixed ARMv7M bug(BLX <label> doesn't exist on that version)

git-svn-id: branches/laksen/arm-embedded@22579 -
2012-10-08 00:10:52 +00:00
pierre
2f24527ea0 Enable gotvarsym for sparc cpu
git-svn-id: trunk@22486 -
2012-09-27 15:55:07 +00:00
svenbarth
e04fae2c67 Remove commented variables which strangely weren't detected by a "make cycle"...
git-svn-id: trunk@22456 -
2012-09-25 11:52:10 +00:00
svenbarth
88af293155 Fix for Mantis #22160
The cause of the internal error was the following:
We have a generic in an unit ("A") which uses another unit ("B") in the implementation section and this other unit uses unit A in the interface section. Now the generic is specialized in the interface section of B. This leads to the problem that in unit A when it tries to load the globalsymtable of unit B that globalsymtable will be Nil, because parsing of the interface section is not yet finished. Thus the change in pgenutil.pas, specialization_init: if the unit is still "in_interface" the localsymtable needs to be used instead of the globalsymtable.

This doesn't necessarily lead to a compiling test though, as there is the following possibility:
Unit A contains a generic class/record (with methods) and uses unit B in the implementation section. This unit B also contains a generic class/record (with methods) and uses unit A in the implementation section. Both units contain a specialization of the other unit's generic outside of it's own generics (such that generate_specialization is fully triggered). Let's assume compilation starts with unit A and we reach the uses of unit B. Now compilation switches to unit B and completes as unit A is already registered and in compilation. The problem now is that the generic in unit A still contains unresolved forward declarations as the implementation section of A was not yet parsed which will lead to "forward declaration not solved" errors (Note: Delphi compiles this).

The solution to this is the following: if a generic is specialized from another unit which is not in state ms_compiled then the unit of the specialization needs to wait for the unit of the generic. So the specialization's unit adds itself into a list of waiting units of the generic's unit. Now inside "proc_unit" we need to check whether this module is waiting for other modules and if so avoid "finishing" the unit (which means generating the methods of the specialization, generating assembler code and ultimately freeing the scanner and PPU). Now when the generic's unit finishes we need to check whether other modules are waiting for it and finish them (of course it's a bit more complicated in reality, but that pretty much sums it up).

+ globstat.pas: Added an unit which handles the saving and restoring of the global state which was originally inside "parser.pas, compile" so that Don't Repeat Yourself (DRY) is respected.
* fmodule.pas, tmodule: 
  + add fields to keep track of the units the module is waiting for and which modules are waiting for the module
  + add field for the saved global state (raw pointer to avoid circles)
  + add field for the state which is needed to finish the unit (raw pointer to avoid circles)
  + move the code which was used in "parser.pas, compile" after a module was successfully compiled to the new virtual method "end_of_parsing"
+ fppu.pas, tppumodule.end_of_parsing:
  free the ppufile here
* pgenutil.pas:
  + add new procedure "maybe_add_waiting_unit" which adds the specialization's unit to the waiting list of the generic if that unit is not yet compiled
  * generate_specialization: call the new function when we add a new (true) specialization
  * specialization_init: instead of not adding implementation units at all check whether the unit is still parsing the interface section and add the localsymtable in that case
* pmodules.pas:
  * change "proc_unit" to a function which returns "true" if the unit was already finished (no need to wait for other units)
  + move the code from "proc_unit" from "generate_specialization_procs" on to a new procedure "finish_unit" which
  * this procedure is either called immediately in "proc_unit" if the unit does not need to wait for other units or from "finish_unit" itself if a unit that is waiting for the given unit does no longer wait for another module (special care is taken in proc_unit to avoid circles)
* parser.pas, compile:
  * correctly handle the case if an unit is not finished
  * use the new global state functionality from globstat.pas
  * pay special attention when calling "set_current_module" (see comment at that call)

+ add tests from 22160
+ add test for above mentioned "diamond" case

git-svn-id: trunk@22452 -
2012-09-25 09:45:25 +00:00