Module: L::LD::LinkerClang

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

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/rub/l/ld/linker/clang.rb', line 32

def self.available?
	!!find
end

.findPathname?

Find the linker executable.

Returns:

  • (Pathname, nil)

    The path of the executable.



38
39
40
# File 'lib/rub/l/ld/linker/clang.rb', line 38

def self.find
	C.find_command 'clang'
end


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rub/l/ld/linker/clang.rb', line 42

def self.link_command(opt, files, libs, out, format)
	files = R::Tool.make_set_paths files
	libs  = R::Tool.make_set       libs
	out = C.path(out)

	c = [find, "-o#{out}"]
	
	c << opt.args
	
	c << case format
		when :exe
			[]
		when :shared
			['-shared']
		else
			raise "Unknown/unsupported output #{format}."
	end
	
	c << case opt.optimize
		when :none
			'-O0'
		when :some
			'-O2'
		when :full
			'-O3'
		when :max
			'-O4'
		else
			raise "Invalid optimization level #{opt.optimize}."
	end
	
	c << if opt.static
		'-static'
	else
		[]
	end
	
	c << opt.library_dirs.map{|d| "-L#{d}"}
	
	#c << libs.map{|l| "-l#{l}" }
	c << libs.map{|l| "#{l}" }
	c << files.to_a
	
	c.flatten
end

.nameObject



28
29
30
# File 'lib/rub/l/ld/linker/clang.rb', line 28

def self.name
	:clang
end