[IR] Reserve/define the purpose for the "Linker Options" metadata flags.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 17 Jan 2013 00:16:27 +0000 (00:16 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 17 Jan 2013 00:16:27 +0000 (00:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172681 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.rst

index d6cdbc4284b69b46c8109668aae0fd2b9114b6cb..6706f34ba691618f0d88014b601eb5c0780cb5f8 100644 (file)
@@ -2610,6 +2610,40 @@ Some important flag interactions:
 -  A module with ``Objective-C Garbage Collection`` set to 0 cannot be
    merged with a module with ``Objective-C GC Only`` set to 6.
 
+Automatic Linker Flags Module Flags Metadata
+--------------------------------------------
+
+Some targets support embedding flags to the linker inside individual object
+files. Typically this is used in conjunction with language extensions which
+allow source files to explicitly declare the libraries they depend on, and have
+these automatically be transmitted to the linker via object files.
+
+These flags are encoded in the IR using metadata in the module flags section,
+using the ``Linker Options`` key. The merge behavior for this flag is required
+to be ``AppendUnique``, and the value for the key is expected to be a metadata
+node which should be a list of other metadata nodes, each of which should be a
+list of metadata strings defining linker options.
+
+For example, the following metadata section specifies two separate sets of
+linker options, presumably to link against ``libz`` and the ``Cocoa``
+framework::
+
+    !0 = metadata !{ i32 6, "Linker Options", 
+       metadata !{
+          !metadata { metadata !"-lz" },
+          !metadata { metadata !"-framework", metadata !"Cocoa" } } }
+    !llvm.module.flags = !{ !0 }
+
+The metadata encoding as lists of lists of options, as opposed to a collapsed
+list of options, is chosen so that the IR encoding can use multiple option
+strings to specify e.g., a single library, while still having that specifier be
+preserved as an atomic element that can be recognized by a target specific
+assembly writer or object file emitter.
+
+Each individual option is required to be either a valid option for the target's
+linker, or an option that is reserved by the target specific assembly writer or
+object file emitter. No other aspect of these options is defined by the IR.
+
 Intrinsic Global Variables
 ==========================