mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
toobj.d unify pragmas lib/linkerdirective (#16847)
* unify pragmas lib/linkerdirective
This commit is contained in:
parent
0e8e67097d
commit
eeeb43a60f
1 changed files with 16 additions and 28 deletions
|
@ -785,7 +785,7 @@ void toObjFile(Dsymbol ds, bool multiobj)
|
|||
|
||||
override void visit(PragmaDeclaration pd)
|
||||
{
|
||||
if (pd.ident == Id.lib)
|
||||
if (pd.ident == Id.lib || pd.ident == Id.linkerDirective)
|
||||
{
|
||||
assert(pd.args && pd.args.length == 1);
|
||||
|
||||
|
@ -795,19 +795,25 @@ void toObjFile(Dsymbol ds, bool multiobj)
|
|||
|
||||
StringExp se = e.isStringExp();
|
||||
char *name = cast(char *)mem.xmalloc(se.numberOfCodeUnits() + 1);
|
||||
|
||||
se.writeTo(name, true);
|
||||
|
||||
/* Embed the library names into the object file.
|
||||
* The linker will then automatically
|
||||
* search that library, too.
|
||||
*/
|
||||
if (!obj_includelib(name[0 .. strlen(name)]))
|
||||
if (pd.ident == Id.linkerDirective)
|
||||
obj_linkerdirective(name);
|
||||
else
|
||||
{
|
||||
/* The format does not allow embedded library names,
|
||||
* so instead append the library name to the list to be passed
|
||||
* to the linker.
|
||||
/* Embed the library names into the object file.
|
||||
* The linker will then automatically
|
||||
* search that library, too.
|
||||
*/
|
||||
global.params.libfiles.push(name);
|
||||
if (!obj_includelib(name[0 .. strlen(name)]))
|
||||
{
|
||||
/* The format does not allow embedded library names,
|
||||
* so instead append the library name to the list to be passed
|
||||
* to the linker.
|
||||
*/
|
||||
global.params.libfiles.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pd.ident == Id.startaddress)
|
||||
|
@ -820,24 +826,6 @@ void toObjFile(Dsymbol ds, bool multiobj)
|
|||
Symbol *s = toSymbol(f);
|
||||
obj_startaddress(s);
|
||||
}
|
||||
else if (pd.ident == Id.linkerDirective)
|
||||
{
|
||||
assert(pd.args && pd.args.length == 1);
|
||||
|
||||
Expression e = (*pd.args)[0];
|
||||
|
||||
assert(e.op == EXP.string_);
|
||||
|
||||
StringExp se = e.isStringExp();
|
||||
size_t length = se.numberOfCodeUnits() + 1;
|
||||
debug enum LEN = 2; else enum LEN = 20;
|
||||
char[LEN] buffer = void;
|
||||
SmallBuffer!char directive = SmallBuffer!char(length, buffer);
|
||||
|
||||
se.writeTo(directive.ptr, true);
|
||||
|
||||
obj_linkerdirective(directive.ptr);
|
||||
}
|
||||
|
||||
visit(cast(AttribDeclaration)pd);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue