Skip to content

Commit fa28d47

Browse files
committed
Add linker flag and LLD support.
1 parent 6d3c962 commit fa28d47

File tree

8 files changed

+69
-0
lines changed

8 files changed

+69
-0
lines changed

src/_premake_init.lua

+10
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,16 @@
892892
}
893893
}
894894

895+
api.register {
896+
name = "linker",
897+
scope = "config",
898+
kind = "string",
899+
allowed = {
900+
"Default",
901+
"LLD",
902+
}
903+
}
904+
895905
api.register {
896906
name = "locale",
897907
scope = "config",

src/tools/clang.lua

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@
253253
if cfg.system == p.WINDOWS then return "-mwindows" end
254254
end,
255255
},
256+
linker = gcc.ldflags.linker,
256257
sanitize = {
257258
Address = "-fsanitize=address",
258259
},

src/tools/gcc.lua

+4
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@
478478
if cfg.system == p.WINDOWS then return "-mwindows" end
479479
end,
480480
},
481+
linker = {
482+
Default = "",
483+
LLD = "-fuse-ld=lld"
484+
},
481485
sanitize = {
482486
Address = "-fsanitize=address",
483487
},

tests/tools/test_clang.lua

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@
106106
test.excludes("-fopenmp", clang.getcflags(cfg))
107107
end
108108

109+
--
110+
-- Check handling of linker flag.
111+
--
112+
113+
function suite.ldflags_linker_lld()
114+
linker "LLD"
115+
prepare()
116+
test.contains("-fuse-ld=lld", clang.getldflags(cfg))
117+
end
118+
109119
--
110120
-- Check the translation of CXXFLAGS.
111121
--

tests/tools/test_gcc.lua

+11
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,17 @@
811811
end
812812

813813

814+
--
815+
-- Check handling of linker flag.
816+
--
817+
818+
function suite.ldflags_linker_lld()
819+
linker "LLD"
820+
prepare()
821+
test.contains("-fuse-ld=lld", gcc.getldflags(cfg))
822+
end
823+
824+
814825
--
815826
-- Check handling of link time optimization flag.
816827
--

website/docs/Linking.md

+4
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ If you need to discover the location of a library, use the [`os.findlib`](os.fin
4040
```lua
4141
libdirs { os.findlib("X11") }
4242
```
43+
44+
### Linker
45+
46+
The linker defaults to the specified toolset default linker, but can be changed with the [`linker`](linker.md) flag.

website/docs/linker.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Specifies the linker.
2+
3+
```lua
4+
linker("value")
5+
```
6+
7+
### Parameters ###
8+
9+
`value` is a string value.
10+
11+
By default, `Default` and `LLD` are allowed, but toolsets or modules canprovide support for other linkers.
12+
13+
### Applies To ###
14+
15+
Project configurations.
16+
17+
### Availability ###
18+
19+
Premake 5.0 beta 3 or later.
20+
21+
### Examples ###
22+
23+
Sets `LLD` as the linker.
24+
25+
```lua
26+
filter { "toolset:clang" }
27+
linker { "LLD" }
28+
```

website/sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ module.exports = {
199199
'largeaddressaware',
200200
'libdirs',
201201
'linkbuildoutputs',
202+
'linker',
202203
'linkgroups',
203204
'linkoptions',
204205
'links',

0 commit comments

Comments
 (0)