Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[runtime-library] Rename the library name ireert into iree #97

Merged
merged 4 commits into from
Jan 19, 2023
Merged

[runtime-library] Rename the library name ireert into iree #97

merged 4 commits into from
Jan 19, 2023

Conversation

wangkuiyi
Copy link
Contributor

@wangkuiyi wangkuiyi commented Jan 19, 2023

The Problem

Currently, for macOS and iOS, we build the IREE runtime into ireert.framework. Header files in /runtime/src is copied to the directory Headers/iree of ireert.framework. Following the convention of Objective-C, in an iOS app, we can import an IREE header file from the framework as the following:

#import "ireert/iree/base/status.h"

where ireert is the framework name, iree is the directory in Headers.

Unfortunately, the build of our Objective-C app would fail because in status.h, there are lines like the following.

#include "iree/base/attributes.h"

Note that this include path does not start with ireert, so the compiler complains not found header file "attributes.h".

Idea 1. Change the IREE runtime code.

A straightforward idea is to change the IREE source code and replace the above line into

#include "ireert/iree/base/attributes.h"

This does not make sense because the IREE authors, when writing the runtime code, have no idea that we will build their work into a framework named ireert.

Idea 2. Add search path in the ireert.framework in Xcode

In Xcode, we can add $(SRCROOT)/ireert.xcframework/arm64-ios-sim/ireert.framework/Headers/iree to the search path, so the compiler can find file like "iree/base/attributes.h".

This is not ideal because we will need to manually add paths for each platform in the XCFramework. We might support more and more platforms in the future, including tvOS and watchOS.

Idea 3. Rename ireert into iree

This is what this pull request does.

In addition to renaming the framework/xcframework, we also change the mapping of header files. Rather than mapping iree/runtime/src/*, we mapiree/runtime/src/iree to Headers.

After the name changing, in our iOS app, we do

#import "iree/base/status.h"

instead of

#import "ireert/iree/base/status.h".

Here, iree is the framework/xcframework name, and base/status.h is in Headers.

This import has the same convention as we already have in the IREE source code, i.e.,

#include "iree/base/attributes.h"

The Result

The following screenshot shows an iOS app developed with Xcode.

  • I added the new iree.xcframework into this Xcode project. This XCFramework includes multiple iree.frameworks, each built for a certain platform.
  • In the Objective-C code, I put #import "iree/base/status.h" to include status.h from the XCFramework.
  • In the status.h file, it can just `#include "iree/base/attributes.h" as is.
  • The Output windows at the bottom of the screenshot shows "OK", which was printed by the call to iree_status_fprint.

Screenshot 2023-01-18 at 2 52 27 PM

Copy link
Collaborator

@stellaraccident stellaraccident left a comment

Choose a reason for hiding this comment

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

With the previous caveats that I am not intimately familiar with this level of iOS packaging, but you seem to know what you are doing/it makes sense to me. I'm open to landing anything that unblocks you here in this way. If it works out, it would be good to review a bit more holistically and better/more officially support framework building. Until then, this makes sense to me.

@stellaraccident stellaraccident merged commit cc06e16 into iree-org:main Jan 19, 2023
@wangkuiyi wangkuiyi changed the title Rename the library name ireert into iree [runtime-library] Rename the library name ireert into iree Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants