Skip to content

Update the Import Script to Include Windows Headers #14

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

Closed
wants to merge 1 commit into from

Conversation

gmittert
Copy link
Contributor

Update the import script and run it to import a new version of llvm. The only file changes are in the first commit. Everything in the second commit should be identical to swift llvm commit ab94816b593daf1c623322b0fb981abb0b156833 except for llvm/Support/Process.cpp with required some hacks in the import-llvm script.

@gmittert gmittert changed the title Run script Update to the latest LLVM and Include Windows Headers Mar 21, 2019
@gmittert
Copy link
Contributor Author

Indexstore includes llvm/ADT/OptionSet.h, which from as far as I can tell is from this patch that never got merged. I've just copied it out and have the import script copy it back in. However really, either the uses of it should be removed, or it should be necroed an merged it.

@benlangmuir
Copy link
Contributor

Instead of moving the import script, I suggest using a different name for the directory containing the files. That will also make it a lot easier to review the changes to that script.

@gmittert gmittert changed the title Update to the latest LLVM and Include Windows Headers Update the Import Script to Include Windows Headers Mar 25, 2019
@gmittert
Copy link
Contributor Author

Alright, modified this one to just be the import script changes. I should be much easier to read now.

@@ -1,3 +1,4 @@
#define LLVM_ENABLE_CRASH_DUMPS false
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the change that was required? It should go into config.h.


# ADT "Small" structures.
ADT_imports += ['SmallPtrSet', 'SmallSet', 'SmallString', 'SmallVector']

# ADT Algorithms.
ADT_imports += ['edit_distance']

Demangle_imports = ['Demangle', 'ItaniumDemangle', 'MicrosoftDemangle',
Copy link
Contributor

Choose a reason for hiding this comment

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

What pulled in the demangler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Support/Unix/Signals.inc includes Demangle.h it uses it to demangle symbols when printing backtraces.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, this was apparently one of the modifications to the files that we warned about at the top of the import script:

char* d = nullptr;//itaniumDemangle(dlinfo.dli_sname, nullptr, nullptr, &res);

I don't think we want to pull in the demangler.

os.symlink(os.path.join('..', '..', '..', 'include', 'llvm'),
os.path.join(sourcekit_llvm_lib, 'include', 'llvm'))
os.symlink(os.path.join('..', '..', '..', 'include', 'llvm-c'),
os.path.join(sourcekit_llvm_lib, 'include', 'llvm-c'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could these symlinks be done by looping over the directories instead of listing them out manually? It's really hard to tell if these are correct by inspection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaned these up a bit, I didn't need as many as I thought I did.

copyfile(os.path.join(sourcekit_srcroot, 'include', 'llvm', 'Support', 'AArch64TargetParser.def'),
os.path.join(def_location, 'AArch64TargetParser.def'))

# Process.cpp uses LLVM_ENABLE_CRASH_DUMPS which is usually set in CMake.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in config.h. In general, it would be good to look at a new config.h from an llvm build, although it will need to be merged manually with what's here, which is already customized. But that more general change doesn't need to happen in this PR.

if os.path.exists(def_location):
shutil.rmtree(def_location)
os.makedirs(def_location)
copyfile(os.path.join(sourcekit_srcroot, 'include', 'llvm', 'Support', 'AArch64TargetParser.def'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the original location get looked at? If not, we could move instead of copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move it is!

'Statistic', 'StringExtras', 'STLExtras', 'AllocatorList', 'Triple']
ADT_imports = ['iterator', 'iterator_range', 'APFloat', 'APInt', 'APSInt',
'AllocatorList', 'EpochTracker', 'Hashing', 'None', 'Optional',
'Statistic', 'StringExtras', 'STLExtras']
Copy link
Contributor

Choose a reason for hiding this comment

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

These lists are getting quite messy. I think we're better off just making each variable into a single list, and putting every dependency on its own line. That will make it much easier to see changes in the future. Splitting it up "thematically" like this made more sense when we had fewer imports and you could still conceivable eyeball changes.

@gmittert gmittert force-pushed the RunScript branch 2 times, most recently from 161f73d to f2f1c1b Compare March 25, 2019 23:14
@benlangmuir
Copy link
Contributor

The TimeValue changes seem to be here too.

'FormatVariadicDetails', 'NativeFormatting', 'DJB', 'ReverseIteration', 'MD5',
'SmallVectorMemoryBuffer', 'WithColor', 'Options', 'PrettyStackTrace', 'Watchdog',
'TargetParser', 'ARMBuildAttributes', 'ARMTargetParser.def', 'AArch64TargetParser.def', 'X86TargetParser.def', 'LineIterator']
'AArch64TargetParser',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Praise be M-x sort-lines

@gmittert
Copy link
Contributor Author

gmittert commented Mar 25, 2019

The TimeValue changes seem to be here too.

Had them in the branch to make sure things compiled, rebased off master, gone now.

'Process',
'Program',
'Recycler',
'Regex',
Copy link
Contributor

Choose a reason for hiding this comment

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

What is pulling in Regex (and all the reg* files below)? If possible it would be nice to avoid this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Timer -> YAML (so it can print JSON) -> Regex. It's just one function that indexstoredb doesn't use, so it could be commented out/removed.

@gmittert gmittert force-pushed the RunScript branch 2 times, most recently from 558d1e0 to c54f669 Compare March 26, 2019 22:03
@gmittert
Copy link
Contributor Author

Alright, added in some super gross sed calls so that Demangle and Regex don't need to be imported.


# Timer.cpp and Statistics.cpp use YAMLTraits to assert some JSON is valid. We don't want to
# pull in the YAML/Regex so we'll remove the "offending" lines.
timer_location = os.path.join(sourcekit_srcroot, 'lib', 'LLVMSupport', 'Support', 'Timer.cpp')
Copy link
Contributor

Choose a reason for hiding this comment

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

Yikes, this is pretty gross. Could we use a patch file instead of doing this with sed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that seems like a much nice way to do it.

Additionally, update it so that it's compatibile with the current stable branch
(ab94816b593daf1c623322b0fb981abb0b156833)
@gmittert
Copy link
Contributor Author

Ping on this one

@akyrtzi
Copy link
Contributor

akyrtzi commented Apr 30, 2019

Apologies, this PR slipped my mind, and I've already gone ahead and imported a new llvm here: #18

I introduced a patch file to avoid adding the regex dependency and to fix include errors (ideally the patch file changes should go to llvm upstream).

I avoided adding the demangle dependency by adding a dummy Demangle.h

I also added the Windows support files.
If there is something missing for Windows support please open a new PR against master.

@akyrtzi akyrtzi closed this Apr 30, 2019
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.

3 participants