Skip to content

Landing support for the LLVM AOT backend on Windows - #3757

Merged
benvanik merged 6 commits into
mainfrom
benvanik-aot-windows
Nov 18, 2020
Merged

benvanik merged 6 commits into
mainfrom
benvanik-aot-windows

Conversation

@benvanik

@benvanik benvanik commented Nov 6, 2020 •

Copy link
Copy Markdown
Collaborator

The primary change here is around how linkers are defined in the compiler and how we use them. There is now a LinkerTool type that allows for target-specific manipulation of the module prior to codegen required for making valid Windows DLLs and can be useful for things like wasm where we may need to expose additional control symbols.

The existing linking behavior is moved into UnixLinkerTool (using ld/ld.lld) while the new Windows support is in (creatively) WindowsLinkerTool. TODOs are in place for mac mach-o and wasm linking, and the UnixLinkerTool could use a lot of work (left for someone who knows more about ld).

I included instructions for the Windows builds and tried to make it as default as possible ("vcvarsall to setup your env then build with the right triple"). Still likely some tuning that could be done to reduce configuration issues but I feel like the UnixLinkerTool needs much more love first :)

Fixes #2645 by providing defaults and useful error messages when not set right.

@google-cla google-cla Bot added the cla: yes label Nov 6, 2020
@benvanik benvanik added codegen Shared code generation infrastructure and dialects compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) enhancement ➕ New feature or request platform/windows 🚪 Windows-specific build, execution, benchmarking, and deployment and removed cla: yes labels Nov 6, 2020
@google-cla google-cla Bot added the cla: yes label Nov 6, 2020
@benvanik benvanik added this to the 2020Q4 Core milestone Nov 6, 2020
@benvanik
benvanik force-pushed the benvanik-aot-windows branch 7 times, most recently from 3746dfc to d63854a Compare November 8, 2020 19:31
@benvanik
benvanik changed the base branch from main to benvanik-aot-windows-prework November 8, 2020 19:34
Base automatically changed from benvanik-aot-windows-prework to main November 9, 2020 17:15
@ScottTodd

Copy link
Copy Markdown
Member

@benvanik

Copy link
Copy Markdown
Collaborator Author

SGTM - will try to rebase today

@benvanik
benvanik force-pushed the benvanik-aot-windows branch from ddee03b to 86aeba2 Compare November 14, 2020 08:33
@benvanik
benvanik marked this pull request as ready for review November 14, 2020 08:37
@benvanik
benvanik requested a review from ScottTodd November 14, 2020 08:37

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, and mostly ready on the branch merging side of things. Let's figure out the failing tests though.

@benvanik

Copy link
Copy Markdown
Collaborator Author

Let's figure out the failing tests though.

I have wsl2 working now so I can try building tensorflow and junk - really not pleased that's the only way to see the errors though :(

@ScottTodd

Copy link
Copy Markdown
Member

Let's figure out the failing tests though.

I have wsl2 working now so I can try building tensorflow and junk - really not pleased that's the only way to see the errors though :(

Yeah, I asked on Discord if anyone could help decipher the errors but got no responses >_>

I suspect that

  • removing LLVM JIT
  • using LLVM AOT for integrations/ tests
  • ensuring LLVM AOT is tested in compiler/

will collectively help, since errors at this level should be caught by the compiler/ tests

benvanik and others added 5 commits November 17, 2020 16:50
This adds the WindowsLinkerTool that uses lld-link or link to generate
the DLLs/PDBs. The existing behavior is modeled in UnixLinkerTool that
is meant for use with ld/ld.lld.

TODOs are in place for mac mach-o and wasm linking, and the UnixLinkerTool
could use a lot of work (left for someone who knows more about ld).
* Fix handling when IREE_LLVMAOT_LINKER_PATH is not set.

* Intentionally leak dylib libraries on exit when tracing.
@benvanik
benvanik force-pushed the benvanik-aot-windows branch from 86aeba2 to e86fe35 Compare November 18, 2020 02:47
benvanik added a commit that referenced this pull request Nov 18, 2020
The LLVM JIT driver is deprecated and going away. These tests should
be using LLVM AOT instead (#2673), but this test infra is scary.
Ideally, this infra would barely be doing any of this per-backend;
there should be few - if any - things exclusively tested by this
path that aren't also covered in core tests that don't build/run
from python. Or at least, the infra should not be doing all of this
via build files (bazel is not a configuration language).

Unblocks #3757 and #3843.
@benvanik
benvanik force-pushed the benvanik-aot-windows branch from e86fe35 to 4ca7353 Compare November 18, 2020 03:48
The LLVM JIT driver is deprecated and going away. These tests should
be using LLVM AOT instead (#2673), but this test infra is scary.
Ideally, this infra would barely be doing any of this per-backend;
there should be few - if any - things exclusively tested by this
path that aren't also covered in core tests that don't build/run
from python. Or at least, the infra should not be doing all of this
via build files (bazel is not a configuration language).

Unblocks #3757 and #3843.
@benvanik
benvanik force-pushed the benvanik-aot-windows branch from 4ca7353 to 4e47a49 Compare November 18, 2020 04:20
@benvanik
benvanik merged commit 26c1e42 into main Nov 18, 2020
@benvanik
benvanik deleted the benvanik-aot-windows branch November 18, 2020 04:57
ScottTodd pushed a commit to ScottTodd/iree that referenced this pull request Nov 18, 2020
The LLVM JIT driver is deprecated and going away. These tests should
be using LLVM AOT instead (iree-org#2673), but this test infra is scary.
Ideally, this infra would barely be doing any of this per-backend;
there should be few - if any - things exclusively tested by this
path that aren't also covered in core tests that don't build/run
from python. Or at least, the infra should not be doing all of this
via build files (bazel is not a configuration language).

Unblocks iree-org#3757 and iree-org#3843.
return mlir::emitRemark(targetOp.getLoc())
<< "Linker artifacts for " << targetOp.getName() << " preserved:\n"
<< " " << linkArtifacts.libraryFile.path;
linkArtifacts.keepAllFiles();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never be executed

ScottTodd added a commit that referenced this pull request Dec 17, 2020
LLVM AOT is now stable enough to run by default on all build/test configurations (mainly thanks to: #3757, #4034, #3928).

We don't see a path to deployment on our primary platforms using LLVM JIT and the backend adds excess maintenance cost in the main repository (e.g. runtime code that depends on LLVM -> slow builds and can't build on Android), so this removes the `llvm-ir` compiler target and corresponding `llvm` HAL backend in favor of the `dylib-llvm-aot` compiler target and `dylib` HAL backend (we have many names for the same components :P).
benvanik pushed a commit that referenced this pull request Dec 22, 2020
LLVM AOT is now stable enough to run by default on all build/test configurations (mainly thanks to: #3757, #4034, #3928).

We don't see a path to deployment on our primary platforms using LLVM JIT and the backend adds excess maintenance cost in the main repository (e.g. runtime code that depends on LLVM -> slow builds and can't build on Android), so this removes the `llvm-ir` compiler target and corresponding `llvm` HAL backend in favor of the `dylib-llvm-aot` compiler target and `dylib` HAL backend (we have many names for the same components :P).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Shared code generation infrastructure and dialects compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) enhancement ➕ New feature or request platform/windows 🚪 Windows-specific build, execution, benchmarking, and deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have a better solution to AOT linker discovery

4 participants