Skip to content

Conversation

jckarter
Copy link
Contributor

Many build systems that support Swift don't use swiftc to drive the linker. To make things
easier for these build systems, also use autolinking to pull in the needed compatibility
libraries. This is less ideal than letting the driver add it at link time, since individual
compile jobs don't know whether they're building an executable or not. Introduce a
-disable-autolink-runtime-compatibility flag, which build systems that do drive the linker
with swiftc can pass to avoid autolinking.

rdar://problem/50057445

@jckarter jckarter requested a review from jrose-apple May 30, 2019 19:36
@jckarter
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

A few comments. Also needs a test case.

@jckarter jckarter force-pushed the runtime-compatibility-autolink branch from 2ed4d44 to cd931ea Compare May 30, 2019 21:57
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter
Copy link
Contributor Author

@jrose-apple How's this look now?

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2ed4d443b5c3a2b1d4b220eeeaf017a5f6f1fc6f

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2ed4d443b5c3a2b1d4b220eeeaf017a5f6f1fc6f

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2ed4d443b5c3a2b1d4b220eeeaf017a5f6f1fc6f

@jckarter jckarter force-pushed the runtime-compatibility-autolink branch from cd931ea to f415685 Compare May 30, 2019 23:03
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cd931ea2fdadfae37c8c07b71dc2a0d7600dd185

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cd931ea2fdadfae37c8c07b71dc2a0d7600dd185

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Looks good, with only a few remaining minor comments. Make sure you're coordinating with @Rostepher about how this will get installed into the toolchain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick (here and elsewhere): double-indent for wrapped lines rather than reverse-indenting until it fits.

Copy link
Member

Choose a reason for hiding this comment

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

clang-format should DTRT

Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to repeat this check because the entire NO-FORCE-LOAD check is negative.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised this works! Since it's matching in reverse order from what it needs. But if it works then okay. (If it doesn't actually work, and it's worth checking, then I think it's okay to just match the first line and trust that we wouldn't generate that for any other reason.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that was what -DAG was for, to allow lines to be matched out of order from how they show up in the output.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is, but I've never tried using that with captures.

@jckarter jckarter force-pushed the runtime-compatibility-autolink branch from f415685 to 2a20e28 Compare May 31, 2019 03:35
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f415685763bee81601f6e3acdc42b572f103bcca

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f415685763bee81601f6e3acdc42b572f103bcca

@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2a20e28f6c48d640ae9d1c42e7fdb76e32177705

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2a20e28f6c48d640ae9d1c42e7fdb76e32177705

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Ugh, I really should finish up my work to introduce the SwiftRuntime thing ... this is becoming a mess (not your change, just all the places we have these adhoc checks)

Copy link
Member

Choose a reason for hiding this comment

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

I think that you can write this more concisely as:

  if (Major == 10 && Minor <= 14)
    return llvm::VersionTuple(5, 0);
  return None;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm writing this with an eye toward it eventually growing more arms. There might be more macOS versions with Swift in them in the near future, but who knows

Copy link
Member

Choose a reason for hiding this comment

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

No need for the else after return

Copy link
Member

Choose a reason for hiding this comment

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

No need for the else after return

Copy link
Member

Choose a reason for hiding this comment

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

clang-format should DTRT

jckarter added 3 commits May 31, 2019 13:11
Many build systems that support Swift don't use swiftc to drive the linker. To make things
easier for these build systems, also use autolinking to pull in the needed compatibility
libraries. This is less ideal than letting the driver add it at link time, since individual
compile jobs don't know whether they're building an executable or not. Introduce a
`-disable-autolink-runtime-compatibility` flag, which build systems that do drive the linker
with swiftc can pass to avoid autolinking.

rdar://problem/50057445
Although it's a static archive, its use is only relevant to dynamically linked builds of the
standard library. (If you're statically linking a Swift runtime into your process, you don't
need to worry about compatibility with older runtimes.)
@jckarter jckarter force-pushed the runtime-compatibility-autolink branch from a2e0fe1 to dd91bc2 Compare May 31, 2019 20:11
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a2e0fe18460a568e8eae5523e5ce798d58f3eccc

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a2e0fe18460a568e8eae5523e5ce798d58f3eccc

BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})

if(SWIFTLIB_INSTALL_WITH_SHARED)
Copy link
Contributor

Choose a reason for hiding this comment

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

For this sort of logic I usually prefer:

set(swift_lib_dir "${SWIFTSTATICLIB_DIR}")
if(SWIFTLIB_INSTALL_WITH_SHARED)
  set(swift_lib_dir "${SWIFTLIB_DIR}")
endif()

STATIC
TARGET_LIBRARY)
TARGET_LIBRARY
INSTALL_WITH_SHARED)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I agree with adding yet another single purpose flag to add_swift_target_library. Is there a more generic purpose here? Say maybe an INSTALL_PATH or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm torn about that too. YAGNI convinced me to stick with just the flag for now. A small generalization in between this and INSTALL_PATH might be to have an INSTALL_AS [SHARED|STATIC] flag, so you could also choose to send dylibs to the static dir and v.v.?

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.

5 participants