Kylix Compiler and RTL
Overview
- Command-line tools - what’s new
- DCC is a native Linux executable
- All-new portable code inline assembler
- Supports MMX, Pentium pro, SIMD, 10 byte data structure
- DCC makes native executables (ELF format, x86)
- Can use .O files with restrictions (no C++)
- Command-line tools - what’s out
- TASM and tools
- Borland make (use GNU make)
- brcc (resource script compiler)
- We’ll provide a way to get binary data and strings into executables
Kylix Compiler and RTL
- Command-line tools – what’s different
- Only '-' for command-line switches
- Colon ':' instead of semicolon ';' for path separator
- ‘;’ Is a valid character for Linux file names
- Resources
- Restrictions on windows resource "rip and replace”
- Resource section is a reserved size, you can replace data
- Can’t change the name or add a resource name
- No introspection (enumeration and discovery) like in windows
- We’ll use ELF format extensions – spec allows new segments
- No resource types
- Editing will not be straightforward
- Position independent code (PIC)
- Linux loader - all code is relocatable (uses EBX)
- Shared objects must use PIC
Kylix Compiler and RTL
- Language syntax - what’s new
- Expression evaluation in conditional defines
- {$IF defined(SomeSymbol) and (SomeConstant < 11.0)}
- And, or, XOR, …
- Libraries / packages compile to shared object (.So)
- DCU for executables
- DPU for PIC code - shared objects
- Unit, program, library keywords
- Case sensitive file name - must match name after keyword
- Conditional LINUX symbol is defined
- Assembler – VMToffset, DMToffset
- Mov eax, VMToffset(TMyObject virtual method)
- Moves the offset # - VMT tables may move around
Kylix Compiler and RTL
- Language syntax - what’s out
- Variables on absolute addresses
- var X: integer absolute $1234;
- You can do absolute variables on another variable
- Conditional symbol WIN32 is not defined
- IFDEF style
- Use $IFDEF WIN32 and $IFDEF LINUX
- Don’t use $ELSE
Kylix Compiler and RTL
- Language syntax
- What's different (still under consideration)
- stdcall mapped to cdecl
- No impact on Pascal code
- Assembler code must clean up calls to cdecl functions
- safecall mapped to cdecl
- Primarily used on windows to handle exceptions
- Turns exceptions into a function result
- Still of some use in RPC calls – use proxies and stubs
- Will affect Pascal code – we’ll try to issue a warning
- Both will have an impact on assembler code
Kylix Compiler and RTL
- Run time library
- What's new
- Portable variants – not the Windows variant
- Includes support for variant arrays and safe arrays
- Support for registering custom variant data types
- Data coercion, data copying, operator operations, method invocation
- Test case already implemented – complex numbers
- WideStrings are reference counted
- What's out
- Units such as ComObj, ComServ, ActiveX, windows
- Safecall exceptions
- Raiselastwin32err, OleCheck, win32check
- ExpandUNCFileName (\\server\filename)
- Drive letter functions – extractfiledrive()
Kylix Compiler and RTL
- Run time library - what’s different
- WideChar is still 2 bytes (Linux wchar_t is 4 bytes)
- Linux system calls don’t use WideChars – they use UTF-8
- AnsiStrings encoded as UTF-8
- On Windows AnsiStrings are multi-byte defined by the locale
- ResourceStrings as UTF-8 in exe file
- IInterface replaces IUnknown as base type
- Use IUnknown for windows interfaces
- Use IInterface for application interfaces
- TResourceStream – pulls from ELF executable
- Component streaming depends on component differences
- TThreads
- OS dependent
- Linux distribution differences
Kylix Compiler and RTL
- Run time library - what’s different
- File system
- Filename case sensitivity
- Uses clause, your code, RTL calls
- File name extensions (.Pas, .dpr, .dfm, .dcu, …)
- Classes, SysUtils, …
- File times in Unix format is different
- Windows packed data 1980
- Linux # of seconds since 1970
- No drive letters (DiskFree, DiskSize, ExtractFileDrive)
- Path name separator is '/' not '\'
- New PathSeparator constant, IsPathDelimiter, IncludeTrailingBackslash, ExtractFilePath, etc will work
Demos
- Text book example
- X Windows example
- Simple CLX
- Questions and (Hopefully) Answers
- Introduction to CLX