metacc 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a14fc8ca9c502275a4cc8105906722c167fb58cf6a269559748da22cf88f83d3
4
- data.tar.gz: f56a289ba4240caf683f8614f5317252753032ad8902cce314a0ab43380d05fd
3
+ metadata.gz: d74b463f2d62a82dbbe422b47e112052a25c95e8c51b957f01ec2545b2f8f227
4
+ data.tar.gz: 510bdbcba0c031de7909db0a989141afbecd9fa33bcf7b5066cf61d3dacc6f49
5
5
  SHA512:
6
- metadata.gz: 2b5c6055a1445b3e0341fbde3da0ca9b76e2cfe021c0c7694be91233a2eb2c68de7f063cc5c2b9b953b697fdfa41f3a949b168eb33790d8544fedeeef90f222a
7
- data.tar.gz: 30b826250c85ce5d7b57c83f81714d7ac51b6e911abed4ea8371e3bc36540f0b29779aeced94b398b7d590ffbbbf608c7ab2929f0d9743a8967824edad8bea59
6
+ metadata.gz: bbfda6722b4f9fa4b59a6be206a1b5ca0503d77f5833dbe5ba07f46525b1f157e4ac5ca7853f0f18ae7efd4f9c2782993a0991e101fd102523323abfeea97dd1
7
+ data.tar.gz: 15f59e0d6f45de8501b38aa6429624dd759d7d7b126ce18c0def60bdd2d56648f4b116483753e2f93da60c3e205ec5fd00813844e59b4975d7e3c81c01cfd590
data/bin/metacc CHANGED
@@ -7,7 +7,13 @@ require "metacc/cli"
7
7
 
8
8
  begin
9
9
  MetaCC::CLI.new.run(ARGV)
10
- rescue MetaCC::CLI::InvalidOption, MetaCC::ToolchainNotFoundError => e
10
+ rescue MetaCC::CLI::InvalidOption,
11
+ MetaCC::ToolchainNotFoundError,
12
+ OptionParser::AmbiguousOption,
13
+ OptionParser::MissingArgument,
14
+ OptionParser::NeedlessArgument,
15
+ OptionParser::InvalidArgument,
16
+ OptionParser::InvalidOption => e
11
17
  warn "#{$0} error: #{e.message}"
12
18
  rescue MetaCC::CompileError => e
13
19
  warn e.message
data/lib/metacc/cli.rb CHANGED
@@ -9,57 +9,23 @@ module MetaCC
9
9
  #
10
10
  # Usage:
11
11
  # metacc <sources...> -o <output> [options] – compile source file(s)
12
- #
13
- # General:
14
- # -Wall -Werror
15
- # --std=c11 --std=c17 --std=c23
16
- # --std=c++11 --std=c++14 --std=c++17 --std=c++20 --std=c++23 --std=c++26
17
- #
18
- # Linking:
19
- # -c – compile only; don't link
20
- # -l, -L - specify linker input
21
- # --shared – produce a shared library
22
- # --static – produce a static library
23
- # --lto - enable link time optimization
24
- # --strip / -s – strip unneeded symbols
25
- #
26
- # Code generation:
27
- # -O0, -O1, -O2, -O3 - Set the optimization level
28
- # -msse4.2 -mavx -mavx2 -mavx512 --arch=native - Compile for the given target
29
- # --no-rtti --no-exceptions
30
- # --pic
31
- #
32
- # Debugging:
33
- # --debug / -g
34
- # --asan --ubsan --msan
35
- #
36
- # Toolchain-specific flags (passed to Driver#compile via xflags:):
37
- # --xmsvc VALUE – appended to xflags[MSVC]
38
- # --xgnu VALUE – appended to xflags[GNU]
39
- # --xclang VALUE – appended to xflags[Clang]
40
- # --xclangcl VALUE – appended to xflags[ClangCL]
41
12
  class CLI
42
13
 
43
- # Maps long-form CLI flag names to Driver::RECOGNIZED_FLAGS symbols.
44
- # Optimization-level flags are handled separately via -O LEVEL.
45
- LONG_FLAGS = {
46
- "lto" => :lto,
47
- "asan" => :asan,
48
- "ubsan" => :ubsan,
49
- "msan" => :msan,
50
- "no-rtti" => :no_rtti,
51
- "no-exceptions" => :no_exceptions,
52
- "pic" => :pic,
53
- "no-semantic-interposition" => :no_semantic_interposition,
54
- "no-omit-frame-pointer" => :no_omit_frame_pointer,
55
- "no-strict-aliasing" => :no_strict_aliasing
56
- }.freeze
57
-
58
14
  WARNING_CONFIGS = {
59
15
  "all" => :warn_all,
60
16
  "error" => :warn_error
61
17
  }
62
18
 
19
+ SANITIZERS = {
20
+ "address" => :asan,
21
+ "addr" => :asan,
22
+ "undefined" => :ubsan,
23
+ "ub" => :ubsan,
24
+ "memory" => :msan,
25
+ "mem" => :msan,
26
+ "leak" => :lsan
27
+ }
28
+
63
29
  TARGETS = {
64
30
  "sse4.2" => :sse4_2,
65
31
  "avx" => :avx,
@@ -85,7 +51,8 @@ module MetaCC
85
51
  "xmsvc" => MSVC,
86
52
  "xgnu" => GNU,
87
53
  "xclang" => Clang,
88
- "xclangcl" => ClangCL
54
+ "xclangcl" => ClangCL,
55
+ "xtinycc" => TinyCC
89
56
  }.freeze
90
57
 
91
58
  def initialize(driver: Driver.new)
@@ -122,6 +89,11 @@ module MetaCC
122
89
  private
123
90
 
124
91
  def setup_compile_options(parser, options)
92
+ parser.require_exact = true
93
+
94
+ parser.separator ""
95
+ parser.separator "General options:"
96
+
125
97
  parser.on("-o FILEPATH", "Output file path") do |value|
126
98
  options[:output_path] = value
127
99
  end
@@ -131,26 +103,72 @@ module MetaCC
131
103
  parser.on("-D DEF", "Add a preprocessor definition") do |value|
132
104
  options[:defs] << value
133
105
  end
134
- parser.on("-O LEVEL", /\A[0-3]|s\z/, "Optimization level (0–3)") do |level|
106
+ parser.on("--std=STANDARD", "Specify the language standard") do |value|
107
+ options[:flags] << STANDARDS[value]
108
+ end
109
+ parser.on("-W OPTION", "Configure warnings") do |value|
110
+ options[:flags] << WARNING_CONFIGS[value]
111
+ end
112
+ parser.on("-r", "--run", "Run the compiled executable after a successful build") do
113
+ options[:run] = true
114
+ end
115
+
116
+ parser.separator ""
117
+ parser.separator "Debugging:"
118
+
119
+ parser.on("-g", "--debug-info", "Emit debugging symbols") do
120
+ options[:flags] << :debug_info
121
+ end
122
+ parser.on("-S", "--sanitize SANITIZER", "Enable sanitizer (address, undefined, leak, memory)") do |value|
123
+ options[:flags] << SANITIZERS[value]
124
+ end
125
+
126
+ parser.separator ""
127
+ parser.separator "Optimization:"
128
+
129
+ parser.on("-O LEVEL", /\A[0-3]|s\z/, "Optimization level (0, 1, 2, 3, or s)") do |level|
135
130
  options[:flags] << :"o#{level}"
136
131
  end
137
- parser.on("-m", "--arch ARCH", "Target architecture") do |value|
132
+ parser.on("--lto", "Enable link time optimization") do
133
+ options[:flags] << :lto
134
+ end
135
+ parser.on("--omit-frame-pointer") do |value|
136
+ options[:flags] << :omit_frame_pointer
137
+ end
138
+ parser.on("--strict-aliasing") do |value|
139
+ options[:flags] << :strict_aliasing
140
+ end
141
+
142
+ parser.separator ""
143
+ parser.separator "Code generation:"
144
+
145
+ parser.on("-m", "--arch=ARCH", "Target architecture") do |value|
138
146
  options[:flags] << TARGETS[value]
139
147
  end
140
- parser.on("-g", "--debug", "Emit debugging symbols") do
141
- options[:flags] << :debug
148
+ parser.on("--pic", "Generate position independent code") do |value|
149
+ options[:flags] << :pic
142
150
  end
143
- parser.on("--std STANDARD", "Specify the language standard") do |value|
144
- options[:flags] << STANDARDS[value]
151
+ parser.on("--no-rtti", "Disable runtime type information") do |value|
152
+ options[:flags] << :no_rtti
145
153
  end
146
- parser.on("-W OPTION", "Configure warnings") do |value|
147
- options[:flags] << WARNING_CONFIGS[value]
154
+ parser.on("--no-exceptions", "Disable exceptions (and unwinding info)") do |value|
155
+ options[:flags] << :no_exceptions
148
156
  end
149
- parser.on("-c", "Produce object files") do
150
- options[:link] = false
157
+
158
+ parser.separator ""
159
+ parser.separator "Linking:"
160
+
161
+ parser.on("--static", "Produce a static library") do
162
+ options[:flags] << :static
151
163
  end
152
- parser.on("-r", "--run", "Run the compiled executable after a successful build") do
153
- options[:run] = true
164
+ parser.on("--shared", "Produce a shared library") do |value|
165
+ options[:flags] << :shared
166
+ end
167
+ parser.on("--shared-compat", "Produce a shared library with full LD_PRELOAD compatability") do |value|
168
+ options[:flags] << :shared_compat
169
+ end
170
+ parser.on("-c", "Compile only (produce object files without linking)") do
171
+ options[:link] = false
154
172
  end
155
173
  parser.on("-l LIB", "Link against library LIB") do |value|
156
174
  options[:libs] << value
@@ -158,43 +176,46 @@ module MetaCC
158
176
  parser.on("-L DIR", "Add linker library search path") do |value|
159
177
  options[:link_paths] << value
160
178
  end
161
- parser.on("--shared", "Produce a shared library") do
162
- options[:flags] << :shared
163
- end
164
- parser.on("--static", "Produce a static library") do
165
- options[:flags] << :static
166
- end
179
+
167
180
  parser.on("-s", "--strip", "Strip unneeded symbols") do
168
181
  options[:flags] << :strip
169
182
  end
170
- LONG_FLAGS.each do |name, sym|
171
- parser.on("--#{name}") do
172
- options[:flags] << sym
173
- end
174
- end
175
- XFLAGS.each do |name, tc_class|
176
- parser.on("--#{name} VALUE", "Pass VALUE to the #{tc_class} toolchain") do |value|
177
- options[:xflags][tc_class] ||= []
178
- options[:xflags][tc_class] << value
183
+
184
+ parser.separator ""
185
+ parser.separator "Compiler specific:"
186
+
187
+ XFLAGS.each do |name, toolchain_class|
188
+ toolchain_name = toolchain_class.name.split("::").last
189
+ parser.on("--#{name} FLAG", "Forward FLAG to the compiler if compiling with #{toolchain_name}") do |value|
190
+ options[:xflags][toolchain_class] ||= []
191
+ options[:xflags][toolchain_class] << value
179
192
  end
180
193
  end
194
+
195
+ parser.separator ""
196
+ parser.separator "Informational:"
197
+
181
198
  parser.on_tail("--version", "Print the toolchain version and exit") do
182
199
  puts @driver.toolchain.version_banner
183
200
  exit
184
201
  end
202
+ parser.on_tail("-h", "--help", "Show this message") do
203
+ puts parser
204
+ exit
205
+ end
185
206
  end
186
207
 
187
208
  def validate_options!(flags, output_path, link:, run:)
188
209
  if !link && output_path
189
- raise InvalidOption, "cannot specify output path (-o) in compile only mode (-c)"
210
+ raise OptionParser::InvalidOption, "cannot specify output path (-o) in compile only mode (-c)"
190
211
  end
191
212
 
192
213
  if link && !output_path
193
- raise InvalidOption, "must specify an output path (-o)"
214
+ raise OptionParser::InvalidOption, "must specify an output path (-o)"
194
215
  end
195
216
 
196
217
  if run && (!link || flags.include?(:shared) || flags.include?(:static))
197
- raise InvalidOption, "--run may not be used with -c, --shared, or --static"
218
+ raise OptionParser::InvalidOption, "--run may not be used with -c, --shared, or --static"
198
219
  end
199
220
  end
200
221
 
@@ -209,8 +230,6 @@ module MetaCC
209
230
  end
210
231
  end
211
232
 
212
- class InvalidOption < StandardError; end
213
-
214
233
  end
215
234
 
216
235
  end
data/lib/metacc/driver.rb CHANGED
@@ -17,16 +17,16 @@ module MetaCC
17
17
 
18
18
  RECOGNIZED_FLAGS = Set.new(
19
19
  %i[
20
- o0 o1 o2 o3 os
21
- sse4_2 avx avx2 avx512 native
22
- debug lto
23
20
  warn_all warn_error
24
21
  c11 c17 c23
25
22
  cxx11 cxx14 cxx17 cxx20 cxx23 cxx26
26
- asan ubsan msan
27
- no_rtti no_exceptions pic
28
- no_semantic_interposition no_omit_frame_pointer no_strict_aliasing
29
- shared static strip
23
+ o0 o1 o2 o3 os lto
24
+ sse4_2 avx avx2 avx512 native
25
+ asan ubsan msan lsan
26
+ debug_info
27
+ omit_frame_pointer strict_aliasing
28
+ no_rtti no_exceptions
29
+ pic shared shared_compat static strip
30
30
  ]
31
31
  ).freeze
32
32
 
@@ -154,6 +154,9 @@ module MetaCC
154
154
  raise "#{unrecognized_flag.inspect} is not a known flag"
155
155
  end
156
156
 
157
+ flags << :no_omit_frame_pointer unless flags.include?(:omit_frame_pointer)
158
+ flags << :no_strict_aliasing unless flags.include?(:strict_aliasing)
159
+
157
160
  flags.flat_map { |flag| @toolchain.flags[flag] }
158
161
  end
159
162
 
@@ -150,41 +150,45 @@ module MetaCC
150
150
  end
151
151
 
152
152
  GNU_FLAGS = {
153
- o0: ["-O0"],
154
- o1: ["-O1"],
155
- o2: ["-O2"],
156
- o3: ["-O3"],
157
- os: ["-Os"],
158
- sse4_2: ["-march=x86-64-v2"], # This is a better match for /arch:SSE4.2 than -msse4_2 is
159
- avx: ["-march=x86-64-v2", "-mavx"],
160
- avx2: ["-march=x86-64-v3"], # This is a better match for /arch:AVX2 than -mavx2 is
161
- avx512: ["-march=x86-64-v4"],
162
- native: ["-march=native", "-mtune=native"],
163
- debug: ["-g3"],
164
- lto: ["-flto"],
165
- warn_all: ["-Wall", "-Wextra", "-pedantic"],
166
- warn_error: ["-Werror"],
167
- c11: ["-std=c11"],
168
- c17: ["-std=c17"],
169
- c23: ["-std=c23"],
170
- cxx11: ["-std=c++11"],
171
- cxx14: ["-std=c++14"],
172
- cxx17: ["-std=c++17"],
173
- cxx20: ["-std=c++20"],
174
- cxx23: ["-std=c++23"],
175
- cxx26: ["-std=c++2c"],
176
- asan: ["-fsanitize=address"],
177
- ubsan: ["-fsanitize=undefined"],
178
- msan: ["-fsanitize=memory"],
179
- no_rtti: ["-fno-rtti"],
180
- no_exceptions: ["-fno-exceptions", "-fno-unwind-tables"],
181
- pic: ["-fPIC"],
182
- no_semantic_interposition: ["-fno-semantic-interposition"],
183
- no_omit_frame_pointer: ["-fno-omit-frame-pointer"],
184
- no_strict_aliasing: ["-fno-strict-aliasing"],
185
- shared: ["-shared"],
186
- static: ["-static"],
187
- strip: ["-Wl,--strip-unneeded"]
153
+ o0: ["-O0"],
154
+ o1: ["-O1"],
155
+ o2: ["-O2"],
156
+ o3: ["-O3"],
157
+ os: ["-Os"],
158
+ sse4_2: ["-march=x86-64-v2"], # This is a better match for /arch:SSE4.2 than -msse4_2 is
159
+ avx: ["-march=x86-64-v2", "-mavx"],
160
+ avx2: ["-march=x86-64-v3"], # This is a better match for /arch:AVX2 than -mavx2 is
161
+ avx512: ["-march=x86-64-v4"],
162
+ native: ["-march=native", "-mtune=native"],
163
+ debug_info: ["-g3"],
164
+ lto: ["-flto"],
165
+ warn_all: ["-Wall", "-Wextra", "-pedantic"],
166
+ warn_error: ["-Werror"],
167
+ c11: ["-std=c11"],
168
+ c17: ["-std=c17"],
169
+ c23: ["-std=c23"],
170
+ cxx11: ["-std=c++11"],
171
+ cxx14: ["-std=c++14"],
172
+ cxx17: ["-std=c++17"],
173
+ cxx20: ["-std=c++20"],
174
+ cxx23: ["-std=c++23"],
175
+ cxx26: ["-std=c++2c"],
176
+ asan: ["-fsanitize=address"],
177
+ ubsan: ["-fsanitize=undefined"],
178
+ msan: ["-fsanitize=memory"],
179
+ lsan: ["-fsanitize=leak"],
180
+ no_rtti: ["-fno-rtti"],
181
+ no_exceptions: ["-fno-exceptions", "-fno-unwind-tables"],
182
+ pic: ["-fPIC"],
183
+ omit_frame_pointer: ["-fomit-frame-pointer"],
184
+ no_omit_frame_pointer: ["-fno-omit-frame-pointer"],
185
+ strict_aliasing: ["-fstrict-aliasing"],
186
+ no_strict_aliasing: ["-fno-strict-aliasing"],
187
+ shared: ["-shared", "-Bsymbolic-non-weak-functions", "-fno-semantic-interposition"],
188
+ shared_compat: ["-shared"],
189
+ static: ["-static"],
190
+ strip: ["-Wl,--strip-unneeded"],
191
+ debug: ["-D_GLIBCXX_DEBUG", "-fasynchronous-unwind-tables"]
188
192
  }.freeze
189
193
 
190
194
  def flags
@@ -254,41 +258,44 @@ module MetaCC
254
258
  end
255
259
 
256
260
  MSVC_FLAGS = {
257
- o0: ["/Od"],
258
- o1: ["/O1"],
259
- o2: ["/O2"],
260
- o3: ["/O2", "/Ob3"],
261
- os: ["/O1"],
262
- sse4_2: ["/arch:SSE4.2"],
263
- avx: ["/arch:AVX"],
264
- avx2: ["/arch:AVX2"],
265
- avx512: ["/arch:AVX512"],
266
- native: [],
267
- debug: ["/Zi"],
268
- lto: ["/GL"],
269
- warn_all: ["/W4"],
270
- warn_error: ["/WX"],
271
- c11: ["/std:c11"],
272
- c17: ["/std:c17"],
273
- c23: ["/std:clatest"],
274
- cxx11: [],
275
- cxx14: ["/std:c++14"],
276
- cxx17: ["/std:c++17"],
277
- cxx20: ["/std:c++20"],
278
- cxx23: ["/std:c++23preview"],
279
- cxx26: ["/std:c++latest"],
280
- asan: ["/fsanitize=address"],
281
- ubsan: [],
282
- msan: [],
283
- no_rtti: ["/GR-"],
284
- no_exceptions: ["/EHs-", "/EHc-"],
285
- pic: [],
286
- no_semantic_interposition: [],
287
- no_omit_frame_pointer: ["/Oy-"],
288
- no_strict_aliasing: [],
289
- shared: ["/LD"],
290
- static: ["/c"],
291
- strip: []
261
+ o0: ["/Od"],
262
+ o1: ["/O1"],
263
+ o2: ["/O2"],
264
+ o3: ["/O2", "/Ob3"],
265
+ os: ["/O1"],
266
+ sse4_2: ["/arch:SSE4.2"],
267
+ avx: ["/arch:AVX"],
268
+ avx2: ["/arch:AVX2"],
269
+ avx512: ["/arch:AVX512"],
270
+ native: [],
271
+ debug_info: ["/Zi"],
272
+ lto: ["/GL"],
273
+ warn_all: ["/W4"],
274
+ warn_error: ["/WX"],
275
+ c11: ["/std:c11"],
276
+ c17: ["/std:c17"],
277
+ c23: ["/std:clatest"],
278
+ cxx11: [],
279
+ cxx14: ["/std:c++14"],
280
+ cxx17: ["/std:c++17"],
281
+ cxx20: ["/std:c++20"],
282
+ cxx23: ["/std:c++23preview"],
283
+ cxx26: ["/std:c++latest"],
284
+ asan: ["/fsanitize=address"],
285
+ ubsan: [],
286
+ msan: [],
287
+ lsan: [],
288
+ no_rtti: ["/GR-"],
289
+ no_exceptions: ["/EHs-", "/EHc-"],
290
+ pic: [],
291
+ omit_frame_pointer: ["/Oy"],
292
+ no_omit_frame_pointer: ["/Oy-"],
293
+ strict_aliasing: ["-fstrict-aliasing"],
294
+ no_strict_aliasing: ["-fno-strict-aliasing"],
295
+ shared: ["/LD"],
296
+ shared_compat: ["/LD"],
297
+ static: ["/c"],
298
+ strip: []
292
299
  }.freeze
293
300
 
294
301
  def flags
@@ -416,6 +423,7 @@ module MetaCC
416
423
  object_files = input_files.map { |f| f.sub(/\.c\z/, ".o") }
417
424
  commands << [@ar, "rcs", output_file, *object_files]
418
425
  end
426
+ commands
419
427
  end
420
428
 
421
429
  # TinyCC does not support C++.
@@ -428,41 +436,42 @@ module MetaCC
428
436
  end
429
437
 
430
438
  TINYCC_FLAGS = {
431
- o0: [],
432
- o1: ["-O1"],
433
- o2: ["-O2"],
434
- o3: ["-O2"],
435
- os: [],
436
- sse4_2: [],
437
- avx: [],
438
- avx2: [],
439
- avx512: [],
440
- native: [],
441
- debug: ["-g"],
442
- lto: [],
443
- warn_all: ["-Wall"],
444
- warn_error: ["-Werror"],
445
- c11: [],
446
- c17: [],
447
- c23: [],
448
- cxx11: [],
449
- cxx14: [],
450
- cxx17: [],
451
- cxx20: [],
452
- cxx23: [],
453
- cxx26: [],
454
- asan: [],
455
- ubsan: [],
456
- msan: [],
457
- no_rtti: [],
458
- no_exceptions: [],
459
- pic: [],
460
- no_semantic_interposition: [],
461
- no_omit_frame_pointer: [],
462
- no_strict_aliasing: [],
463
- shared: ["-shared"],
464
- static: ["-c"],
465
- strip: []
439
+ o0: [],
440
+ o1: ["-O1"],
441
+ o2: ["-O2"],
442
+ o3: ["-O2"],
443
+ os: [],
444
+ sse4_2: [],
445
+ avx: [],
446
+ avx2: [],
447
+ avx512: [],
448
+ native: [],
449
+ debug_info: ["-g"],
450
+ lto: [],
451
+ warn_all: ["-Wall"],
452
+ warn_error: ["-Werror"],
453
+ c11: [],
454
+ c17: [],
455
+ c23: [],
456
+ cxx11: [],
457
+ cxx14: [],
458
+ cxx17: [],
459
+ cxx20: [],
460
+ cxx23: [],
461
+ cxx26: [],
462
+ asan: [],
463
+ ubsan: [],
464
+ msan: [],
465
+ leak: [],
466
+ no_rtti: [],
467
+ no_exceptions: [],
468
+ pic: [],
469
+ keep_frame_pointer: [],
470
+ relaxed_aliasing: [],
471
+ shared: ["-shared"],
472
+ shared_compat: ["-shared"],
473
+ static: ["-c"],
474
+ strip: []
466
475
  }.freeze
467
476
 
468
477
  def flags
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MetaCC
2
4
 
3
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
4
6
 
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metacc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Praneeth Sadda