Skip to content

Commit c95e8f7

Browse files
committed
Merge branch 'hipcc-symlink' of https://github.com/raramakr/HIPCC into kzhuravl/packaging
2 parents 2f3b708 + 78a5d49 commit c95e8f7

File tree

12 files changed

+1191
-17
lines changed

12 files changed

+1191
-17
lines changed

amd/hipcc/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Merge files created by git.
2+
*.orig
3+
# Reject files created by patch.
4+
*.rej
5+
6+
# Nested build directory.
7+
/build*

amd/hipcc/CMakeLists.txt

Lines changed: 109 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,117 @@
1-
cmake_minimum_required(VERSION 3.16.3)
2-
project (hipcc.bin)
1+
cmake_minimum_required(VERSION 3.13.4)
2+
3+
project(hipcc VERSION "1.0.0" LANGUAGES C CXX)
4+
set(hipcc_NAME "${PROJECT_NAME}")
5+
6+
include(CMakePackageConfigHelpers)
7+
include(GNUInstallDirs)
8+
9+
find_package(ROCM)
10+
if(ROCM_FOUND)
11+
include(ROCMSetupVersion)
12+
rocm_setup_version(VERSION "${hipcc_VERSION}")
13+
endif()
314

4-
# Specify the C++ standard
515
set(CMAKE_CXX_STANDARD 17)
616
set(CMAKE_CXX_STANDARD_REQUIRED True)
717

8-
set (LINK_LIBS libstdc++fs.so)
9-
add_executable(hipcc.bin src/hipBin.cpp)
10-
if (NOT WIN32) # C++17 does not require the std lib linking
11-
target_link_libraries(hipcc.bin ${LINK_LIBS} ) # for hipcc.bin
18+
set(ADDITIONAL_SHARED_LIBRARIES_TO_LINK
19+
libstdc++fs.so)
20+
21+
get_directory_property(HAS_PARENT_SCOPE PARENT_DIRECTORY)
22+
if(HAS_PARENT_SCOPE)
23+
# FIXME(kzhuravl): Do we need these here? If yes, what is the default?
24+
set(HIP_VERSION_MAJOR 4 PARENT_SCOPE)
25+
set(HIP_VERSION_MINOR 4 PARENT_SCOPE)
26+
set(HIP_VERSION_PATCH 4 PARENT_SCOPE)
27+
else()
28+
message(STATUS "Current scope has no parent")
29+
endif()
30+
31+
set(HIPCC_BIN
32+
hipcc.bin)
33+
set(HIPCC_SOURCES
34+
src/hipBin.cpp)
35+
36+
set(HIPCONFIG_BIN
37+
hipconfig.bin)
38+
set(HIPCONFIG_SOURCES
39+
src/hipBin.cpp)
40+
41+
add_executable(${HIPCC_BIN} ${HIPCC_SOURCES})
42+
if(NOT WIN32)
43+
# C++17 does not require std lib linking.
44+
target_link_libraries(${HIPCC_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK})
45+
endif()
46+
47+
add_executable(${HIPCONFIG_BIN} ${HIPCONFIG_SOURCES})
48+
if(NOT WIN32)
49+
# C++17 does not require std lib linking.
50+
target_link_libraries(${HIPCONFIG_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK})
51+
endif()
52+
53+
set(CPACK_GENERATOR "DEB;RPM;ZIP" CACHE STRING "Default packaging generators")
54+
set(CPACK_PACKAGE_CONTACT "ROCm Compiler Support <[email protected]>")
55+
set(CPACK_PACKAGE_DESCRIPTION "HIP Compiler Driver")
56+
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
57+
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
58+
set(CPACK_PACKAGE_VERSION_MAJOR "${hipcc_VERSION_MAJOR}")
59+
set(CPACK_PACKAGE_VERSION_MINOR "${hipcc_VERSION_MINOR}")
60+
set(CPACK_PACKAGE_VERSION_PATCH "${hipcc_VERSION_PATCH}")
61+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
62+
63+
# Debian-specific packaging variables.
64+
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
65+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC")
66+
if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
67+
set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
68+
else()
69+
set(CPACK_DEBIAN_PACKAGE_RELEASE "local")
70+
endif()
71+
72+
# RPM-specific packaging variables.
73+
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
74+
set(CPACK_RPM_PACKAGE_LICENSE "NCSA")
75+
if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE})
76+
set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE})
77+
else()
78+
set(CPACK_RPM_PACKAGE_RELEASE "local")
79+
endif()
80+
if(CPACK_RPM_PACKAGE_RELEASE)
81+
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
82+
endif()
83+
84+
# ROCM versioning.
85+
set(ROCM_VERSION_FOR_PACKAGE "")
86+
if(DEFINED ENV{ROCM_LIBPATCH_VERSION})
87+
set(ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_LIBPATCH_VERSION})
88+
elseif(DEFINED ENV{ROCM_VERSION})
89+
string(REGEX REPLACE "." "" ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_VERSION})
90+
else()
91+
set(ROCM_VERSION_FOR_PACKAGE "99999")
1292
endif()
93+
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}")
1394

14-
project (hipconfig.bin)
15-
add_executable(hipconfig.bin src/hipBin.cpp)
16-
if (NOT WIN32) # C++17 does not require the std lib linking
17-
target_link_libraries(hipconfig.bin ${LINK_LIBS} ) # for hipconfig.bin
95+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
96+
DESTINATION .
97+
USE_SOURCE_PERMISSIONS)
98+
install(FILES
99+
"LICENSE.txt"
100+
"README.md"
101+
COMPONENT ${hipcc_NAME}
102+
DESTINATION ${CMAKE_INSTALL_DOCDIR})
103+
install(TARGETS ${HIPCC_BIN}
104+
COMPONENT ${hipcc_NAME}
105+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
106+
install(TARGETS ${HIPCONFIG_BIN}
107+
COMPONENT ${hipcc_NAME}
108+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
109+
# TODO: WIN32 check need to be removed if backward compatibility is required for WIN32
110+
option(HIPCC_BACKWARD_COMPATIBILITY "Enable HIPCC backward compatibility" ON)
111+
if(NOT WIN32)
112+
if(HIPCC_BACKWARD_COMPATIBILITY)
113+
include(hipcc-backward-compat.cmake)
114+
endif()
18115
endif()
19116

20-
set(HIP_VERSION_MAJOR 4 PARENT_SCOPE)
21-
set(HIP_VERSION_MINOR 4 PARENT_SCOPE)
22-
set(HIP_VERSION_PATCH 4 PARENT_SCOPE)
117+
include(CPack)

amd/hipcc/bin/hipcc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env perl
2+
# Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
# Need perl > 5.10 to use logic-defined or
23+
use 5.006; use v5.10.1;
24+
25+
use warnings;
26+
27+
use File::Basename;
28+
use File::Spec::Functions 'catfile';
29+
30+
# TODO: By default select perl script until change incorporated in HIP build script.
31+
my $USE_PERL_SCRIPT = $ENV{'HIP_USE_PERL_SCRIPTS'};
32+
$USE_PERL_SCRIPT //= 1; # use defined-or assignment operator. Use env var, but if not defined default to 1.
33+
34+
my $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys');
35+
# escapes args with quotes SWDEV-341955
36+
foreach $arg (@ARGV) {
37+
if ($isWindows) {
38+
$arg =~ s/[^-a-zA-Z0-9_=+,.:\/\\ ]/\\$&/g;
39+
}
40+
}
41+
42+
my $SCRIPT_DIR=dirname(__FILE__);
43+
if ($USE_PERL_SCRIPT) {
44+
#Invoke hipcc.pl
45+
my $HIPCC_PERL=catfile($SCRIPT_DIR, '/hipcc.pl');
46+
system($^X, $HIPCC_PERL, @ARGV);
47+
} else {
48+
$BIN_NAME="/hipcc.bin";
49+
if ($isWindows) {
50+
$BIN_NAME="/hipcc.bin.exe";
51+
}
52+
my $HIPCC_BIN=catfile($SCRIPT_DIR, $BIN_NAME);
53+
if ( -e $HIPCC_BIN ) {
54+
#Invoke hipcc.bin
55+
system($HIPCC_BIN, @ARGV);
56+
} else {
57+
print "hipcc.bin not present; Install HIPCC binaries before proceeding";
58+
exit(-1);
59+
}
60+
}
61+
62+
# Because of this wrapper we need to check
63+
# the output of the system command for perl and bin
64+
# else the failures are ignored and build fails silently
65+
if ($? == -1) {
66+
exit($?);
67+
}
68+
elsif ($? & 127) {
69+
exit($?);
70+
}
71+
else {
72+
$CMD_EXIT_CODE = $? >> 8;
73+
}
74+
exit($CMD_EXIT_CODE);

amd/hipcc/bin/hipcc.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@set HIPCC="%~dp0hipcc"
2+
@perl %HIPCC% %*

0 commit comments

Comments
 (0)