Skip to content

Commit 2a38be3

Browse files
committed
Add LLVM clang '-emit-llvm' MBS option
Allows the user to configure clang to generate object code or LLVM bitcode. The previous behaviour (bitcode generation) remains the default.
1 parent 9b61c23 commit 2a38be3

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

llvm/org.eclipse.cdt.managedbuilder.llvm.ui/plugin.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ Option.Posix.Linker.native=Create native binary (with LLVM native code generator
173173
Option.Posix.Linker.nativeCBackend=Create native binary (with C backend code generator)
174174
Option.Posix.Static.Compiler.Flags=Static Compiler Flags
175175

176+
Option.Llvm.Clang.EmitLlvm.name=Emit LLVM IR (-emit-llvm)
177+
Option.Llvm.Clang.EmitLlvm.tip=Generate LLVM bitcode (not object code)
178+
176179
Option.Llvm.printStats=Print statistics
177180
Option.Llvm.Archiver.Flags=Archiver flags
178181
Option.Llvm.Llc.Flags=LLC flags

llvm/org.eclipse.cdt.managedbuilder.llvm.ui/plugin.xml

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<?eclipse version="3.4"?>
3+
<!--
4+
Copyright (c) 2010-2025 Nokia Siemens Networks Oyj and others
5+
This program and the accompanying materials
6+
are made available under the terms of the Eclipse Public License 2.0
7+
which accompanies this distribution, and is available at
8+
https://www.eclipse.org/legal/epl-2.0/
9+
10+
SPDX-License-Identifier: EPL-2.0
11+
12+
Contributors:
13+
Nokia Siemens Networks - initial implementation
14+
John Dallaway - add option for clang '-emit-llvm' (#1277)
15+
-->
316
<plugin>
417
<extension
518
id="org.eclipse.cdt.managedbuilder.llvm.ui.buildDefinitions"
@@ -210,7 +223,7 @@
210223
<inputType
211224
buildVariable="BCS"
212225
dependencyCalculator="org.eclipse.cdt.managedbuilder.llvm.makegen.LlvmDependencyCalculator2"
213-
id="cdt.managedbuild.tool.llvm.c.linker.input"
226+
id="cdt.managedbuild.tool.llvm.c.linker.input.bc"
214227
multipleOfType="true"
215228
primaryInput="true"
216229
sourceContentType="org.eclipse.cdt.managedbuilder.llvm.ui.llvmBytecode"
@@ -224,6 +237,15 @@
224237
paths="$(LIBS)">
225238
</additionalInput>
226239
</inputType>
240+
<inputType
241+
buildVariable="OBJS"
242+
dependencyCalculator="org.eclipse.cdt.managedbuilder.llvm.makegen.LlvmDependencyCalculator2"
243+
id="cdt.managedbuild.tool.llvm.c.linker.input.obj"
244+
multipleOfType="true"
245+
primaryInput="true"
246+
sourceContentType="org.eclipse.cdt.managedbuilder.core.compiledObjectFile"
247+
sources="o">
248+
</inputType>
227249
<outputType
228250
buildVariable="LLVM_BC_EXECUTABLES"
229251
id="cdt.managedbuild.tool.llvm.c.linker.output.exe.bc"
@@ -317,8 +339,9 @@
317339
<inputType
318340
buildVariable="BCS"
319341
dependencyCalculator="org.eclipse.cdt.managedbuilder.llvm.makegen.LlvmDependencyCalculator2"
320-
id="cdt.managedbuild.tool.llvm.archiver.input"
342+
id="cdt.managedbuild.tool.llvm.archiver.input.bc"
321343
multipleOfType="true"
344+
primaryInput="true"
322345
sourceContentType="org.eclipse.cdt.managedbuilder.llvm.ui.llvmBytecode"
323346
sources="bc">
324347
<additionalInput
@@ -330,6 +353,15 @@
330353
paths="$(LIBS)">
331354
</additionalInput>
332355
</inputType>
356+
<inputType
357+
buildVariable="OBJS"
358+
dependencyCalculator="org.eclipse.cdt.managedbuilder.llvm.makegen.LlvmDependencyCalculator2"
359+
id="cdt.managedbuild.tool.llvm.archiver.input.obj"
360+
multipleOfType="true"
361+
primaryInput="true"
362+
sourceContentType="org.eclipse.cdt.managedbuilder.core.compiledObjectFile"
363+
sources="o">
364+
</inputType>
333365
<outputType
334366
buildVariable="ARCHIVES"
335367
id="cdt.managedbuild.tool.llvm.archiver.output"
@@ -814,9 +846,17 @@
814846
category="llvm.c_cpp.compiler.category.optimization"
815847
id="llvm.c_cpp.compiler.option.optimization.flags"
816848
name="%Option.Posix.Optimize.Flags"
817-
value="-emit-llvm"
818849
valueType="string">
819850
</option>
851+
<option
852+
category="llvm.c_cpp.compiler.category.optimization"
853+
command="-emit-llvm"
854+
defaultValue="true"
855+
id="llvm.c_cpp.compiler.option.optimization.emit-llvm"
856+
name="%Option.Llvm.Clang.EmitLlvm.name"
857+
tip="%Option.Llvm.Clang.EmitLlvm.tip"
858+
valueType="boolean">
859+
</option>
820860
<optionCategory
821861
id="llvm.c_cpp.compiler.category.debug"
822862
name="%OptionCategory.Debug"
@@ -1047,8 +1087,27 @@
10471087
</option>
10481088
<outputType
10491089
buildVariable="BCS"
1050-
id="cdt.managedbuild.tool.llvm.c_cpp.compiler.output"
1090+
id="cdt.managedbuild.tool.llvm.c_cpp.compiler.output.bc"
10511091
outputs="bc">
1092+
<enablement
1093+
type="ALL">
1094+
<checkOption
1095+
optionId="llvm.c_cpp.compiler.option.optimization.emit-llvm"
1096+
value="true">
1097+
</checkOption>
1098+
</enablement>
1099+
</outputType>
1100+
<outputType
1101+
buildVariable="OBJS"
1102+
id="cdt.managedbuild.tool.llvm.c_cpp.compiler.output.obj"
1103+
outputs="o">
1104+
<enablement
1105+
type="ALL">
1106+
<checkOption
1107+
optionId="llvm.c_cpp.compiler.option.optimization.emit-llvm"
1108+
value="false">
1109+
</checkOption>
1110+
</enablement>
10521111
</outputType>
10531112
</tool>
10541113
<tool

0 commit comments

Comments
 (0)