Skip to content

Commit

Permalink
Merge pull request JuliaLang#14863 from JuliaLang/tk/usrbin
Browse files Browse the repository at this point in the history
RFC: Segregate binaries created by deps out of usr/bin
  • Loading branch information
tkelman committed Jun 4, 2016
2 parents a6d5577 + 6539fd7 commit e55f726
Show file tree
Hide file tree
Showing 18 changed files with 283 additions and 26 deletions.
5 changes: 3 additions & 2 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ sysconfdir := $(prefix)/etc
build_prefix := $(BUILDROOT)/usr
build_staging := $(build_prefix)-staging
build_bindir := $(build_prefix)/bin
build_depsbindir := $(build_prefix)/tools
build_libdir := $(build_prefix)/lib
build_libexecdir := $(build_prefix)/libexec
build_datarootdir := $(build_prefix)/share
Expand Down Expand Up @@ -707,7 +708,7 @@ ifeq ($(origin LLVM_CONFIG), undefined)
ifeq ($(USE_SYSTEM_LLVM), 1)
LLVM_CONFIG := llvm-config$(EXE)
else
LLVM_CONFIG := $(build_bindir)/llvm-config$(EXE)
LLVM_CONFIG := $(build_depsbindir)/llvm-config$(EXE)
endif
endif # LLVM_CONFIG undefined

Expand All @@ -734,7 +735,7 @@ endif
ifeq ($(USE_SYSTEM_PCRE), 1)
PCRE_CONFIG := pcre2-config
else
PCRE_CONFIG := $(build_bindir)/pcre2-config
PCRE_CONFIG := $(build_depsbindir)/pcre2-config
endif

# Use ILP64 BLAS interface when building openblas from source on 64-bit architectures
Expand Down
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default: $(JULIA_BUILD_MODE) # contains either "debug" or "release"
all: debug release

# sort is used to remove potential duplicates
DIRS := $(sort $(build_bindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_man1dir))
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_man1dir))
ifneq ($(BUILDROOT),$(JULIAHOME))
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src ui doc deps test test/perf)
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS))
Expand Down Expand Up @@ -229,8 +229,8 @@ endef
$(eval $(call sysimg_builder,,-O3,$(JULIA_EXECUTABLE_release)))
$(eval $(call sysimg_builder,-debug,-O0,$(JULIA_EXECUTABLE_debug)))

$(build_bindir)/stringreplace: $(JULIAHOME)/contrib/stringreplace.c | $(build_bindir)
@$(call PRINT_CC, $(HOSTCC) -o $(build_bindir)/stringreplace $(JULIAHOME)/contrib/stringreplace.c)
$(build_depsbindir)/stringreplace: $(JULIAHOME)/contrib/stringreplace.c | $(build_depsbindir)
@$(call PRINT_CC, $(HOSTCC) -o $(build_depsbindir)/stringreplace $(JULIAHOME)/contrib/stringreplace.c)


# public libraries, that are installed in $(prefix)/lib
Expand Down Expand Up @@ -297,9 +297,11 @@ endif

ifeq ($(OS),WINNT)
define std_dll
julia-deps: | $$(build_bindir)/lib$(1).dll
julia-deps: | $$(build_bindir)/lib$(1).dll $$(build_depsbindir)/lib$(1).dll
$$(build_bindir)/lib$(1).dll: | $$(build_bindir)
cp $$(call pathsearch,lib$(1).dll,$$(STD_LIB_PATH)) $$(build_bindir) ;
cp $$(call pathsearch,lib$(1).dll,$$(STD_LIB_PATH)) $$(build_bindir)
$$(build_depsbindir)/lib$(1).dll: | $$(build_depsbindir)
cp $$(call pathsearch,lib$(1).dll,$$(STD_LIB_PATH)) $$(build_depsbindir)
JL_LIBS += $(1)
endef
$(eval $(call std_dll,gfortran-3))
Expand All @@ -313,10 +315,10 @@ endif
$(eval $(call std_dll,ssp-0))
endif
define stringreplace
$(build_bindir)/stringreplace $$(strings -t x - $1 | grep '$2' | awk '{print $$1;}') '$3' 255 "$(call cygpath_w,$1)"
$(build_depsbindir)/stringreplace $$(strings -t x - $1 | grep '$2' | awk '{print $$1;}') '$3' 255 "$(call cygpath_w,$1)"
endef

install: $(build_bindir)/stringreplace $(BUILDROOT)/doc/_build/html
install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html
@$(MAKE) $(QUIET_MAKE) all
@for subdir in $(bindir) $(libexecdir) $(datarootdir)/julia/site/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir); do \
mkdir -p $(DESTDIR)$$subdir; \
Expand Down Expand Up @@ -532,7 +534,7 @@ clean: | $(CLEAN_TARGETS)
@-$(MAKE) -C $(BUILDROOT)/test clean
-rm -f $(BUILDROOT)/julia
-rm -f $(BUILDROOT)/*.tar.gz
-rm -f $(build_bindir)/stringreplace \
-rm -f $(build_depsbindir)/stringreplace \
$(BUILDROOT)/light-source-dist.tmp $(BUILDROOT)/light-source-dist.tmp1 \
$(BUILDROOT)/full-source-dist.tmp $(BUILDROOT)/full-source-dist.tmp1
-rm -fr $(build_private_libdir)
Expand Down Expand Up @@ -637,7 +639,7 @@ endif
ifeq ($(USE_SYSTEM_LLVM), 1)
LLVM_SIZE := llvm-size$(EXE)
else
LLVM_SIZE := $(build_bindir)/llvm-size$(EXE)
LLVM_SIZE := $(build_depsbindir)/llvm-size$(EXE)
endif
build-stats:
@echo $(JULCOLOR)' ==> ./julia binary sizes'$(ENDCOLOR)
Expand Down
9 changes: 5 additions & 4 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ include $(SRCDIR)/llvm-ver.make

## Some shared configuration options ##

CONFIGURE_COMMON := --prefix=$(abspath $(build_prefix)) --build=$(BUILD_MACHINE) --libdir=$(abspath $(build_libdir)) $(CUSTOM_LD_LIBRARY_PATH)
CONFIGURE_COMMON := --prefix=$(abspath $(build_prefix)) --build=$(BUILD_MACHINE) --libdir=$(abspath $(build_libdir)) --bindir=$(abspath $(build_depsbindir)) $(CUSTOM_LD_LIBRARY_PATH)
ifneq ($(XC_HOST),)
CONFIGURE_COMMON += --host=$(XC_HOST)
endif
Expand All @@ -47,6 +47,7 @@ CMAKE_CC_ARG := $(CC_ARG) $(DEPS_CFLAGS)
CMAKE_CXX_ARG := $(CXX_ARG) $(DEPS_CXXFLAGS)

CMAKE_COMMON := -DCMAKE_INSTALL_PREFIX:PATH=$(build_prefix)
CMAKE_COMMON += -DCMAKE_INSTALL_BINDIR:PATH=$(shell $(JULIAHOME)/contrib/relative_path.sh $(build_prefix) $(build_depsbindir))
ifneq ($(VERBOSE), 0)
CMAKE_COMMON += -DCMAKE_VERBOSE_MAKEFILE=ON
endif
Expand Down Expand Up @@ -79,7 +80,7 @@ endif

# If the top-level Makefile is called with environment variables,
# they will override the values passed above to ./configure
MAKE_COMMON := DESTDIR="" prefix=$(build_prefix) bindir=$(build_bindir) libdir=$(build_libdir) libexecdir=$(build_libexecdir) datarootdir=$(build_datarootdir) includedir=$(build_includedir) sysconfdir=$(build_sysconfdir) O=
MAKE_COMMON := DESTDIR="" prefix=$(build_prefix) bindir=$(build_depsbindir) libdir=$(build_libdir) shlibdir=$(build_shlibdir) libexecdir=$(build_libexecdir) datarootdir=$(build_datarootdir) includedir=$(build_includedir) sysconfdir=$(build_sysconfdir) O=


## Overall configuration of which rules exist and should be run by default ##
Expand Down Expand Up @@ -114,7 +115,7 @@ endif
ifeq ($(OS), Linux)
ifeq ($(USE_SYSTEM_PATCHELF), 0)
STAGE1_DEPS += patchelf
PATCHELF:=$(build_bindir)/patchelf
PATCHELF:=$(build_depsbindir)/patchelf
else
PATCHELF:=patchelf
endif
Expand Down Expand Up @@ -219,7 +220,7 @@ getall: get-llvm get-libuv get-pcre get-openlibm get-openspecfun get-dsfmt get-R

## PATHS ##
# sort is used to remove potential duplicates
DIRS := $(sort $(build_bindir) $(build_libdir) $(build_includedir) $(build_sysconfdir) $(build_datarootdir) $(build_staging))
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_includedir) $(build_sysconfdir) $(build_datarootdir) $(build_staging))

$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))

Expand Down
1 change: 1 addition & 0 deletions deps/NATIVE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# ref http://lists.llvm.org/pipermail/llvm-dev/2016-February/095366.html
set(CMAKE_C_COMPILER cc)
set(CMAKE_CXX_COMPILER c++)
set(CMAKE_INSTALL_BINDIR tools)
4 changes: 2 additions & 2 deletions deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ SUITESPARSE_VER = 4.4.5
UNWIND_VER = 1.1-julia2
OSXUNWIND_VER = 0.0.3
GMP_VER = 6.1.0
MPFR_VER = 3.1.3
PATCHELF_VER = 0.8
MPFR_VER = 3.1.4
PATCHELF_VER = 0.9
GIT_VER = 1.8.5.6
VIRTUALENV_VER = 15.0.0
RMATH_JULIA_VER = 0.1
1 change: 0 additions & 1 deletion deps/checksums/mpfr-3.1.3.tar.bz2/md5

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/mpfr-3.1.3.tar.bz2/sha512

This file was deleted.

1 change: 1 addition & 0 deletions deps/checksums/mpfr-3.1.4.tar.bz2/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b8a2f6b0e68bef46e53da2ac439e1cf4
1 change: 1 addition & 0 deletions deps/checksums/mpfr-3.1.4.tar.bz2/sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
51066066ff2c12ed2198605ecf68846b0c96b548adafa5b80e0c786d0df488411a5e8973358fce7192dc977ad4e68414cf14500e3c39746de62465eb145bb819
1 change: 0 additions & 1 deletion deps/checksums/patchelf-0.8.tar.gz/md5

This file was deleted.

1 change: 0 additions & 1 deletion deps/checksums/patchelf-0.8.tar.gz/sha512

This file was deleted.

1 change: 1 addition & 0 deletions deps/checksums/patchelf-0.9.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3c265508526760f233620f35d79c79fc
1 change: 1 addition & 0 deletions deps/checksums/patchelf-0.9.tar.gz/sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
715db21156e6bd91cfa626f5201b32a6619e51532f5635ef52396da8193738ba66113485b61cc1e218b16737e66f72cc2e4bb3a7a33e73061ac2ef2c6330a299
213 changes: 213 additions & 0 deletions deps/llvm-3.7.1_symlinks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
commit f4dd81db3c617f22881446eb0ed6bfdc7d69e81e
Author: Chris Bieneman <[email protected]>
Date: Mon Sep 14 23:09:06 2015 +0000

[CMake] Refactor and cleanup generating and installing symlinks to tools.

Summary: This change generalizes symlink generation and makes symlinks to tools obey LLVM_TOOLCHAIN_TOOLS. It makes it so that if you exclude llvm-ar from LLVM_TOOLCHAIN_TOOLS you don't end up with broken symlinks to llvm-lib and llvm-ranlib in your install.

Reviewers: bogner, chapuni, rafael

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12864

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247632 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 2ec309f7d116b6f10cf7dc4ca481aa69ddbe1e5b)

Conflicts:
cmake/modules/AddLLVM.cmake

[CMake] Rename target->dest as per feedback from Chapuni on http://reviews.llvm.org/D12864

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247658 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 5d1cac1aa28e02fda6be52b5ddf4940085df64d9)

[CMake] More refactoring of symlink creation.

This refactoring is to enable clang to re-use this code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247850 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 2334ac1e4cc684bf1f68ac47b4486cf5d4dc8528)

[CMake] More cleanup of installing symlinks.

In order to support building clang out-of-tree the install_symlink script needs to be installed, and it needs to be found by searching the CMAKE_MODULE_PATH.

This change renames install_symlink -> LLVMInstallSymlink so it doesn't conflict with naming from other projects, and adds searching behavior in AddLLVM.cmake

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248009 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit f8d6e92d57aacf9388e8ed87cc43b22bd3367c4f)

[CMake] Adding ALWAYS_GENERATE option to symlink utility functions.

This implements the behavior required for clang symlinks which should be always generated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248039 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 907451c6d653f5d0f4efa55fb42a84dae67a37cc)

[CMake] Cleaning up and generalizing the LLVMInstallSymlink script so that it can be used for libraries too.

In order to resolve PR25059, we're going to need to be able to generate symlinks to libraries manually, so I need this code to be reusable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250573 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 26751e15750dbb733946c940e8a3bdfc5c446d8e)

diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 45f6746..7f711ce 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -602,9 +602,10 @@ function(export_executable_symbols target)
endif()
endfunction()

-
set (LLVM_TOOLCHAIN_TOOLS
llvm-ar
+ llvm-ranlib
+ llvm-lib
llvm-objdump
)

@@ -939,3 +940,77 @@ function(add_lit_testsuites project directory)
endforeach()
endif()
endfunction()
+
+function(llvm_install_symlink name dest)
+ cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
+ foreach(path ${CMAKE_MODULE_PATH})
+ if(EXISTS ${path}/LLVMInstallSymlink.cmake)
+ set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
+ break()
+ endif()
+ endforeach()
+
+ if(ARG_ALWAYS_GENERATE)
+ set(component ${dest})
+ else()
+ set(component ${name})
+ endif()
+
+ set(full_name ${name}${CMAKE_EXECUTABLE_SUFFIX})
+ set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
+
+ install(SCRIPT ${INSTALL_SYMLINK}
+ CODE "install_symlink(${full_name} ${full_dest} bin)"
+ COMPONENT ${component})
+
+ if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
+ add_custom_target(install-${name}
+ DEPENDS ${name} ${dest} install-${dest}
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=${name}
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ endif()
+endfunction()
+
+function(add_llvm_tool_symlink name dest)
+ cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
+ if(UNIX)
+ set(LLVM_LINK_OR_COPY create_symlink)
+ set(dest_binary "${dest}${CMAKE_EXECUTABLE_SUFFIX}")
+ else()
+ set(LLVM_LINK_OR_COPY copy)
+ set(dest_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/${dest}${CMAKE_EXECUTABLE_SUFFIX}")
+ endif()
+
+ set(output_path "${LLVM_RUNTIME_OUTPUT_INTDIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}")
+
+ if(ARG_ALWAYS_GENERATE)
+ set_property(DIRECTORY APPEND PROPERTY
+ ADDITIONAL_MAKE_CLEAN_FILES ${dest_binary})
+ add_custom_command(TARGET ${dest} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}")
+ else()
+ add_custom_command(OUTPUT ${output_path}
+ COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}"
+ DEPENDS ${dest})
+ add_custom_target(${name} ALL DEPENDS ${output_path})
+ set_target_properties(${name} PROPERTIES FOLDER Tools)
+
+ # Make sure the parent tool is a toolchain tool, otherwise exclude this tool
+ list(FIND LLVM_TOOLCHAIN_TOOLS ${dest} LLVM_IS_${dest}_TOOLCHAIN_TOOL)
+ if (NOT LLVM_IS_${dest}_TOOLCHAIN_TOOL GREATER -1)
+ set(LLVM_IS_${name}_TOOLCHAIN_TOOL ${LLVM_IS_${dest}_TOOLCHAIN_TOOL})
+ else()
+ list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
+ endif()
+
+ # LLVM_IS_${name}_TOOLCHAIN_TOOL will only be greater than -1 if both this
+ # tool and its parent tool are in LLVM_TOOLCHAIN_TOOLS
+ if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+ if( LLVM_BUILD_TOOLS )
+ llvm_install_symlink(${name} ${dest})
+ endif()
+ endif()
+ endif()
+endfunction()
+
diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake
new file mode 100644
index 0000000..482697b
--- /dev/null
+++ b/cmake/modules/LLVMInstallSymlink.cmake
@@ -0,0 +1,21 @@
+# We need to execute this script at installation time because the
+# DESTDIR environment variable may be unset at configuration time.
+# See PR8397.
+
+function(install_symlink name target outdir)
+ if(UNIX)
+ set(LINK_OR_COPY create_symlink)
+ set(DESTDIR $ENV{DESTDIR})
+ else()
+ set(LINK_OR_COPY copy)
+ endif()
+
+ set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
+
+ message("Creating ${name}")
+
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}"
+ WORKING_DIRECTORY "${bindir}")
+
+endfunction()
diff --git a/tools/llvm-ar/CMakeLists.txt b/tools/llvm-ar/CMakeLists.txt
index 05ffe36..86233df 100644
--- a/tools/llvm-ar/CMakeLists.txt
+++ b/tools/llvm-ar/CMakeLists.txt
@@ -10,30 +10,5 @@ add_llvm_tool(llvm-ar
llvm-ar.cpp
)

-if(UNIX)
- set(LLVM_LINK_OR_COPY create_symlink)
- set(llvm_ar_binary "llvm-ar${CMAKE_EXECUTABLE_SUFFIX}")
-else()
- set(LLVM_LINK_OR_COPY copy)
- set(llvm_ar_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar${CMAKE_EXECUTABLE_SUFFIX}")
-endif()
-
-set(llvm_ranlib "${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib${CMAKE_EXECUTABLE_SUFFIX}")
-
-add_custom_command(OUTPUT ${llvm_ranlib}
- COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${llvm_ar_binary}" "${llvm_ranlib}"
- DEPENDS llvm-ar)
-
-add_custom_target(llvm-ranlib ALL DEPENDS ${llvm_ranlib})
-set_target_properties(llvm-ranlib PROPERTIES FOLDER Tools)
-
-set(llvm_lib "${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lib${CMAKE_EXECUTABLE_SUFFIX}")
-
-add_custom_command(OUTPUT ${llvm_lib}
- COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${llvm_ar_binary}" "${llvm_lib}"
- DEPENDS llvm-ar)
-
-add_custom_target(llvm-lib ALL DEPENDS ${llvm_lib})
-set_target_properties(llvm-lib PROPERTIES FOLDER Tools)
-
-install(SCRIPT install_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
+add_llvm_tool_symlink(llvm-ranlib llvm-ar)
+add_llvm_tool_symlink(llvm-lib llvm-ar)
Loading

0 comments on commit e55f726

Please sign in to comment.