Module: L::LD

Defined in:
lib/rub/l/ld.rb,
lib/rub/l/ld/linker/ld.rb,
lib/rub/l/ld/linker/gcc.rb,
lib/rub/l/ld/linker/clang.rb

Overview

#

This software is provided 'as-is', without any express or implied           #
warranty. In no event will the authors be held liable for any damages       #
arising from the use of this software.                                      #
                                                                            #
Permission is granted to anyone to use this software for any purpose,       #
including commercial applications, and to alter it and redistribute it      #
freely, subject to the following restrictions:                              #
                                                                            #
1. The origin of this software must not be misrepresented; you must not     #
   claim that you wrote the original software. If you use this software in  #
   a product, an acknowledgment in the product documentation would be       #
   appreciated but is not required.                                         #
                                                                            #
2. Altered source versions must be plainly marked as such, and must not be  #
   misrepresented as being the original software.                           #
                                                                            #
3. This notice may not be removed or altered from any source distribution.  #
                                                                            #

Defined Under Namespace

Modules: Linker, LinkerClang, LinkerGCC, LinkerLD Classes: LibraryArray

Class Method Summary collapse

Class Method Details

.argsArray<String>

Note:

This adds raw arguments to the linker command and is a quick n’ easy way to reduce portability. If you can, use the other options provided by this class in order to maintain portability.

Default arguments to add to the linker command.

Returns:

  • (Array<String>)

    A list of arguments to add.



85
# File 'lib/rub/l/ld.rb', line 85

cattr_accessor :args

.initialize_copy(s) ⇒ Object



249
250
251
252
253
# File 'lib/rub/l/ld.rb', line 249

def self.initialize_copy(s)
	super
	
	self.library_dirs = s.library_dirs.dup
end

.library_dirsArray<Pathname>

A list of library search directories to be added to the default search path.

These paths are searched in order.

Returns:

  • (Array<Pathname>)


67
# File 'lib/rub/l/ld.rb', line 67

cattr_accessor :library_dirs

Link object files.

Parameters:

  • src (Set<Pathname,String>, Array<Pathname,String>, Pathname, String)

    The object files to link.

  • libs (Set<String>, Array<String>, String)

    Libraries to link with.

  • name (Pathname, String)

    The basename of the output file.

  • format (Symbol) (defaults to: :exe)

    The type of output to produce. One of:

    :exe

    An executable binary.

    :shared

    A shared library.

  • linker (Symbol)

    The linker to use. If nil, use the default.

Returns:

  • (Pathname)

    The output file.



235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/rub/l/ld.rb', line 235

def self.link(src, libs, name, format: :exe)
	src  = R::Tool.make_set_paths src
	libs = R::Tool.make_set libs
	
	libfs = libs.map {|l| linker.find_lib(self, l) or raise "Can't find library #{l}."}
	
	out = linker.full_name name, format
	out = R::Env.out_dir + 'l/ld/' + C.unique_segment(src, libs, self) + out
	
	C::generator(src+libfs, linker.link_command(self, src, libs, out, format), out)
	
	out
end

.linkerLinker

The linker being used.

Returns:



38
# File 'lib/rub/l/ld.rb', line 38

cattr_accessor :linker

.linkersHash{Symbol=>Linker}

All available linkers.

Returns:



32
# File 'lib/rub/l/ld.rb', line 32

cattr_reader :linkers

.optimizeSymbol

Default optimization level.

This takes one of four optimization levels. The actual optimization done is linker dependant. For example, some linker may not have any optimization so all levels will be equivalent.

One of the following:

:none

Perform no optimization. This should be fast and debuggable.

:some

Perform light optimization that is pretty fast.

:full

Perform a high level of optimization producing a fast binary. this may considerably slow down compilation.

:max

Perform all available optimizations. These may be experimental and very slow.

This value defaults to :full if D:debug is set, otherwise :none.

Returns:

  • (Symbol)


58
# File 'lib/rub/l/ld.rb', line 58

cattr_accessor :optimize

.set_linker(name) ⇒ Object



92
93
94
# File 'lib/rub/l/ld.rb', line 92

def self.set_linker(name)
	self.linker = linkers[name]
end

.statictrue, false

The default for static linking.

If set to true shared libraries won’t be used. Defaults to false.

Returns:

  • (true, false)


75
# File 'lib/rub/l/ld.rb', line 75

cattr_accessor :static