This is an archive of the discontinued LLVM Phabricator instance.

[Solaris] detect Solaris LD, use detection results to pass Solaris-ld options
ClosedPublic

Authored by fedor.sergeev on Jul 12 2017, 1:16 PM.

Details

Summary

Solaris ld is not the only linker available on Solaris.
Introducing linker detection and using LLVM_LINKER_IS_SOLARISLD to select Solaris-ld specific handling.

Diff Detail

Repository
rL LLVM

Event Timeline

fedor.sergeev created this revision.Jul 12 2017, 1:16 PM

Tested on Solaris x86/SPARC with gcc and clang setup to run Solari ld.
Tested on Linux x86 with gcc and clang setup to run different kinds of linkers (Gold, Gnu, LLD).

Note, that there is also existing code in cmake/modules/HandleLLVMOptions.cmake that runs sorta linker detection for Windows,
as well as setting up variables that describe linker features like LLVM_HAVE_LINK_VERSION_SCRIPT.

Ideally it all should be centralized in one place and handle each and every platform.

I'm not trying to be that ambitious here. Just expanding on what already existed.

ruiu edited edge metadata.Jul 12 2017, 1:39 PM

I'm not sure if you need this. At least for https://bugs.llvm.org/show_bug.cgi?id=33698, it seems you can use --color-diagnostics (instead of -color-diagnostics).

In D35325#807079, @ruiu wrote:

I'm not sure if you need this. At least for https://bugs.llvm.org/show_bug.cgi?id=33698, it seems you can use --color-diagnostics (instead of -color-diagnostics).

33698 is not the only reason to know "is-Solaris-ld" answer.

There are more places where linker flags are being handled and where SunOS assumed == Solaris-ld, which is wrong:

cmake/modules/AddLLVM.cmake:
      COMMENT "Creating export file for ${target_name}")
      if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
        set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                    LINK_FLAGS "  -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
ruiu added a comment.Jul 12 2017, 2:11 PM

It is then perhaps better to add a use of LLVM_LINKER_IS_SOLARISLD to this patch to demonstrate that this patch has at least one usage?

In D35325#807140, @ruiu wrote:

It is then perhaps better to add a use of LLVM_LINKER_IS_SOLARISLD to this patch to demonstrate that this patch has at least one usage?

Okey, I thought the preferred way is to break commits into small ones.

fedor.sergeev retitled this revision from [CMake] linker detection now handles Gnu LD, Solaris LD and LLD to [Solaris] detect Solaris LD, use detection results to pass Solaris-ld options.
fedor.sergeev edited the summary of this revision. (Show Details)

One usage of LLVM_LINKER_IS_SOLARISLD added.

ruiu accepted this revision.Jul 12 2017, 2:28 PM

LGTM

This revision is now accepted and ready to land.Jul 12 2017, 2:28 PM

No commit rights yet :(
Somebody, please, commit!

ruiu added a comment.Jul 12 2017, 2:36 PM

I'll do that for you.

This revision was automatically updated to reflect the committed changes.