This is an archive of the discontinued LLVM Phabricator instance.

add the ability to call InitTargetOptionsFromCodeGenFlags from multiple objects
ClosedPublic

Authored by inglorion on Jan 23 2017, 3:56 PM.

Details

Summary

llvm/CodeGen/CommandFlags.h a utility function InitTargetOptionsFromCodeGenFlags which is used to set target options from flags based on the command line. The command line flags are stored in globals defined in the same file, and including the file in multiple places causes the globals to be defined multiple times, leading to linker errors. This change adds a single place in lld where these globals are defined and exports only the utility function. This makes it possible to call InitTargetOptionsFromCodeGenFlags from multiple places in lld, which a follow-up change will do.

Event Timeline

inglorion created this revision.Jan 23 2017, 3:56 PM
ruiu edited edge metadata.Jan 23 2017, 4:09 PM

Are you actually going to use InitTargetOptionsFromCodeGenFlag function defined in this patch in future?

davide accepted this revision.Jan 28 2017, 12:39 AM

The code LGTM. If Rui/Peter think it's OK to ship this for COFF, I'm fine with this going in.

This revision is now accepted and ready to land.Jan 28 2017, 12:39 AM
ruiu added a comment.Jan 31 2017, 3:04 PM

Sorry for the belated response. I think this should live under lld/lib/Core instead of lld/lib/Config because this is not a configuration or something.

inglorion updated this revision to Diff 86675.Feb 1 2017, 11:04 AM

Good point, @ruiu. Moved this to Core.

ruiu accepted this revision.Feb 1 2017, 11:16 AM

LGTM

lib/Core/TargetOptionsCommandFlags.cpp
28

I'd remove the outer namespace and s/InitTarget/lld::InitTarget/.

LGTM assuming you plan to use this in the COFF lld backend.

inglorion updated this revision to Diff 86910.Feb 2 2017, 3:54 PM

removed outer namespace and put it on the function instead

This revision was automatically updated to reflect the committed changes.
inglorion marked an inline comment as done.