Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Update makefiles for clang 14 or newer

オープン
#6 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
c
領域
build-system

調査の方向性

1_square/Makefile とその他のサンプル Makefile から始め、それらの clang-12 および LLVMEnzyme への参照を、文書化されている clang/opt ワークフローと比較します。clang 14 または 15 で失敗を再現し、その後、単一ファイルおよびマルチソースのサンプルが更新された make targets を通じて正常にビルドおよび実行できることを確認します。

索引モデルが issue の本文から書いたものです。

説明

I'm trying these examples on clang v14 and v15 (on an Ubuntu box) and they fail with some variant of ld.lld: error: undefined symbol: __enzyme_autodiff or square.c:(.text+0x3a): undefined reference to '__enzyme_autodiff' depending on what linker I use.

For example, using regular gnu ld and making the following changes to the Makefile

$ git diff --word-diff Makefile
diff --git a/1_square/Makefile b/1_square/Makefile
index c223268..b4f278a 100644
--- a/1_square/Makefile
+++ b/1_square/Makefile
@@ -4,7 +4,8 @@ clean:
        rm -f *.o *.ll

%.o: %.c
        [-../dockerscript.sh clang-12 /host/$^-]{+clang $^+} -O3 -Xclang -load -Xclang [-/Enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so-]{+../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so+} -ffast-math -o [-/host/$@-]{+$@+}

I obtain:

clang square.c -O3 -Xclang -load -Xclang ../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so -ffast-math -o square.o
/usr/bin/ld: /tmp/square-977b64.o: in function `main':
square.c:(.text+0x3a): undefined reference to `__enzyme_autodiff'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:7: square.o] Error 1

Adding -fpass-plugin=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so for the new pass-manager does not change anything.

The possibly most consequential change to the Makefile is probably the switch from ClangEnzyme-version.so to LLVMEnzyme-version.so. Is that the root cause to this problem? If so, how does one build the former? There is no mention of ClangEnzyme in the cmake_install.cmake of Enzyme version da97fda9aeef27e827a8803f31c40d1b90d0f4a0 (origin/jmp/dataflow-activity-analysis).

As a workaround, I can manually run each step as described at https://enzyme.mit.edu/getting_started/UsingEnzyme/ and that works:

$ clang square.c -S -emit-llvm -o input.ll -O2 -fno-vectorize -fno-slp-vectorize -fno-unroll-loops
$ opt -enable-new-pm=0 input.ll -load=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so -enzyme -o output.ll -S
$ opt output.ll -O2 -o output_opt.ll -S
$ clang output_opt.ll -o a.exe
$ ./a.exe 3.14
Gradient square(3.140000) = 6.280000

However that is good only for single-file examples. The optcommand can't be made to work for multisource, as far as I understand it, since both opt and clang -S can only deal with one source file at the time and one would need two for this purpose:

$ clang multisource.c -S -emit-llvm -o multisource.ll -fno-vectorize -fno-slp-vectorize -fno-unroll-loops
$ clang myblas.c -S -emit-llvm -o myblas.ll -fno-vectorize -fno-slp-vectorize -fno-unroll-loops
$ opt -enable-new-pm=0 myblas.ll -load=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so -enzyme -o myblas_out.ll -S
$ opt -enable-new-pm=0 multisource.ll -load=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so -enzyme -o multisource_out.ll -S
error: <unknown>:0:0: in function preprocess_dotabs double (%struct.complex*, %struct.complex*, i32): Enzyme: No reverse pass found for myblas_cabs
 at context:   %7 = call double @myblas_cabs(double %5, double %6) #7

$ opt -enable-new-pm=0 myblas.ll multisource.ll -load=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so -enzyme -o multisource+myblas_out.ll -S
opt: Too many positional arguments specified!
Can specify at most 1 positional arguments: See: opt --help

$ clang multisource.c myblas.c -S -emit-llvm -o multisource+myblas.ll -fno-vectorize -fno-slp-vectorize -fno-unroll-loops
clang: error: cannot specify -o when generating multiple output files

so how can one fix that case?

@wsmoses sorry if the question is very trivial, but I've been unable to find guidance in the existing examples and documentation, either here or on https://github.com/EnzymeAD/Enzyme

主要言語
Jupyter Notebook
スター
21
フォーク
8
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

EnzymeAD/Enzyme-Tutorial のほかの issue

EnzymeAD/Enzyme-Tutorial の issue をすべて見る

似ている issue

Build System の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。