summary refs log tree commit diff
path: root/tests/run-make/comment-section/Makefile
blob: d0b98176ffed977482718bdfba9bcfc502e838b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Both GCC and Clang write by default a `.comment` section with compiler information. Rustc received a similar .comment section, so this tests checks that this section properly appears.
# See https://github.com/rust-lang/rust/commit/74b8d324eb77a8f337b35dc68ac91b0c2c06debc

include ../tools.mk

# only-linux

all:
	echo 'fn main(){}' | $(RUSTC) - --emit=link,obj -Csave-temps --target=$(TARGET)

	# Check linked output has a `.comment` section with the expected content.
	readelf -p '.comment' $(TMPDIR)/rust_out | $(CGREP) -F 'rustc version 1.'

	# Check all object files (including temporary outputs) have a `.comment`
	# section with the expected content.
	set -e; for f in $(TMPDIR)/*.o; do \
		readelf -p '.comment' $$f | $(CGREP) -F 'rustc version 1.'; \
	done