implemented --dynlibOverride option for static linking of 'dynlib'
This commit is contained in:
parent
c4edcf3ea2
commit
5893a9195c
6 changed files with 34 additions and 3 deletions
|
|
@ -594,6 +594,7 @@ type
|
||||||
TLib* = object of lists.TListEntry # also misused for headers!
|
TLib* = object of lists.TListEntry # also misused for headers!
|
||||||
kind*: TLibKind
|
kind*: TLibKind
|
||||||
generated*: bool # needed for the backends:
|
generated*: bool # needed for the backends:
|
||||||
|
isOverriden*: bool
|
||||||
name*: PRope
|
name*: PRope
|
||||||
path*: PNode # can be a string literal!
|
path*: PNode # can be a string literal!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,11 @@ proc track(arg: string, info: TLineInfo) =
|
||||||
LocalError(info, errInvalidNumber, a[2])
|
LocalError(info, errInvalidNumber, a[2])
|
||||||
msgs.addCheckpoint(newLineInfo(a[0], line, column))
|
msgs.addCheckpoint(newLineInfo(a[0], line, column))
|
||||||
|
|
||||||
|
proc dynlibOverride(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
|
||||||
|
if pass in {passCmd2, passPP}:
|
||||||
|
expectArg(switch, arg, pass, info)
|
||||||
|
options.inclDynlibOverride(arg)
|
||||||
|
|
||||||
proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
|
proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
|
||||||
var
|
var
|
||||||
theOS: TSystemOS
|
theOS: TSystemOS
|
||||||
|
|
@ -480,6 +485,8 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
|
||||||
of "listfullpaths":
|
of "listfullpaths":
|
||||||
expectNoArg(switch, arg, pass, info)
|
expectNoArg(switch, arg, pass, info)
|
||||||
gListFullPaths = true
|
gListFullPaths = true
|
||||||
|
of "dynliboverride":
|
||||||
|
dynlibOverride(switch, arg, pass, info)
|
||||||
else:
|
else:
|
||||||
if strutils.find(switch, '.') >= 0: options.setConfigVar(switch, arg)
|
if strutils.find(switch, '.') >= 0: options.setConfigVar(switch, arg)
|
||||||
else: InvalidCmdLineOption(pass, switch, info)
|
else: InvalidCmdLineOption(pass, switch, info)
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ const
|
||||||
# additional configuration variables:
|
# additional configuration variables:
|
||||||
var
|
var
|
||||||
gConfigVars* = newStringTable(modeStyleInsensitive)
|
gConfigVars* = newStringTable(modeStyleInsensitive)
|
||||||
|
gDllOverrides = newStringtable(modeCaseInsensitive)
|
||||||
libpath* = ""
|
libpath* = ""
|
||||||
gProjectName* = "" # holds a name like 'nimrod'
|
gProjectName* = "" # holds a name like 'nimrod'
|
||||||
gProjectPath* = "" # holds a path like /home/alice/projects/nimrod/compiler/
|
gProjectPath* = "" # holds a path like /home/alice/projects/nimrod/compiler/
|
||||||
|
|
@ -256,6 +257,20 @@ proc libCandidates*(s: string, dest: var seq[string]) =
|
||||||
else:
|
else:
|
||||||
add(dest, s)
|
add(dest, s)
|
||||||
|
|
||||||
|
proc canonDynlibName(s: string): string =
|
||||||
|
let start = if s.startsWith("lib"): 3 else: 0
|
||||||
|
let ende = strutils.find(s, {'(', ')', '.'})
|
||||||
|
if ende >= 0:
|
||||||
|
result = s.substr(start, ende-1)
|
||||||
|
else:
|
||||||
|
result = s.substr(start)
|
||||||
|
|
||||||
|
proc inclDynlibOverride*(lib: string) =
|
||||||
|
gDllOverrides[lib.canonDynlibName] = "true"
|
||||||
|
|
||||||
|
proc isDynlibOverride*(lib: string): bool =
|
||||||
|
result = gDllOverrides.hasKey(lib.canonDynlibName)
|
||||||
|
|
||||||
proc binaryStrSearch*(x: openarray[string], y: string): int =
|
proc binaryStrSearch*(x: openarray[string], y: string): int =
|
||||||
var a = 0
|
var a = 0
|
||||||
var b = len(x) - 1
|
var b = len(x) - 1
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,8 @@ proc getLib(c: PContext, kind: TLibKind, path: PNode): PLib =
|
||||||
result = newLib(kind)
|
result = newLib(kind)
|
||||||
result.path = path
|
result.path = path
|
||||||
Append(c.libs, result)
|
Append(c.libs, result)
|
||||||
|
if path.kind in {nkStrLit..nkTripleStrLit}:
|
||||||
|
result.isOverriden = options.isDynLibOverride(path.strVal)
|
||||||
|
|
||||||
proc expectDynlibNode(c: PContext, n: PNode): PNode =
|
proc expectDynlibNode(c: PContext, n: PNode): PNode =
|
||||||
if n.kind != nkExprColonExpr:
|
if n.kind != nkExprColonExpr:
|
||||||
|
|
@ -225,8 +227,9 @@ proc processDynLib(c: PContext, n: PNode, sym: PSym) =
|
||||||
else:
|
else:
|
||||||
if n.kind == nkExprColonExpr:
|
if n.kind == nkExprColonExpr:
|
||||||
var lib = getLib(c, libDynamic, expectDynlibNode(c, n))
|
var lib = getLib(c, libDynamic, expectDynlibNode(c, n))
|
||||||
addToLib(lib, sym)
|
if not lib.isOverriden:
|
||||||
incl(sym.loc.flags, lfDynamicLib)
|
addToLib(lib, sym)
|
||||||
|
incl(sym.loc.flags, lfDynamicLib)
|
||||||
else:
|
else:
|
||||||
incl(sym.loc.flags, lfExportLib)
|
incl(sym.loc.flags, lfExportLib)
|
||||||
# since we'll be loading the dynlib symbols dynamically, we must use
|
# since we'll be loading the dynlib symbols dynamically, we must use
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,11 @@ Advanced options:
|
||||||
--putenv:key=value set an environment variable
|
--putenv:key=value set an environment variable
|
||||||
--babelPath:PATH add a path for Babel support
|
--babelPath:PATH add a path for Babel support
|
||||||
--excludePath:PATH exclude a path from the list of search paths
|
--excludePath:PATH exclude a path from the list of search paths
|
||||||
|
--dynlibOverride:SYMBOL marks SYMBOL so that dynlib:SYMBOL
|
||||||
|
has no effect and can be statically linked instead;
|
||||||
|
symbol matching is fuzzy so
|
||||||
|
that --dynlibOverride:lua matches
|
||||||
|
dynlib: "liblua.so.3"
|
||||||
--listCmd list the commands used to execute external programs
|
--listCmd list the commands used to execute external programs
|
||||||
--parallelBuild=0|1|... perform a parallel build
|
--parallelBuild=0|1|... perform a parallel build
|
||||||
value = number of processors (0 for auto-detect)
|
value = number of processors (0 for auto-detect)
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -1,7 +1,6 @@
|
||||||
version 0.9.2
|
version 0.9.2
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- a project wide override option for 'dynlib'
|
|
||||||
- FFI:
|
- FFI:
|
||||||
* test libffi on windows
|
* test libffi on windows
|
||||||
* test: times.format with the FFI
|
* test: times.format with the FFI
|
||||||
|
|
@ -29,6 +28,7 @@ Bugs
|
||||||
version 0.9.4
|
version 0.9.4
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
- ``try`` as an expression
|
||||||
- provide tool/API to track leaks/object counts
|
- provide tool/API to track leaks/object counts
|
||||||
- hybrid GC
|
- hybrid GC
|
||||||
- use big blocks in the allocator
|
- use big blocks in the allocator
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue