components/golang-17/Makefile
changeset 7518 c388d4e1d3ad
parent 6911 7b878dfe6f0d
child 7524 a7edbc5545e0
equal deleted inserted replaced
7517:42ae3923b8fe 7518:c388d4e1d3ad
       
     1 #
       
     2 # CDDL HEADER START
       
     3 #
       
     4 # The contents of this file are subject to the terms of the
       
     5 # Common Development and Distribution License (the "License").
       
     6 # You may not use this file except in compliance with the License.
       
     7 #
       
     8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9 # or http://www.opensolaris.org/os/licensing.
       
    10 # See the License for the specific language governing permissions
       
    11 # and limitations under the License.
       
    12 #
       
    13 # When distributing Covered Code, include this CDDL HEADER in each
       
    14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15 # If applicable, add the following below this CDDL HEADER, with the
       
    16 # fields enclosed by brackets "[]" replaced with your own identifying
       
    17 # information: Portions Copyright [yyyy] [name of copyright owner]
       
    18 #
       
    19 # CDDL HEADER END
       
    20 #
       
    21 
       
    22 #
       
    23 # Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
       
    24 #
       
    25 BUILD_BITS= 64
       
    26 COMPILER= gcc
       
    27 # The golang build process just doesn't work with Parfait.
       
    28 export PARFAIT_BUILD=no
       
    29 include ../../make-rules/shared-macros.mk
       
    30 
       
    31 PATCH_EACH_ARCHIVE= 1
       
    32 
       
    33 COMPONENT_NAME=		golang
       
    34 COMPONENT_VERSION=	1.7
       
    35 COMPONENT_MAJOR_VERSION=	$(shell echo $(COMPONENT_VERSION) | $(GSED) -e 's/\([0-9]\+\.[0-9]\+\).*/\1/')
       
    36 COMPONENT_PROJECT_URL=	https://golang.org/
       
    37 COMPONENT_ARCHIVE=	go$(COMPONENT_VERSION).src.tar.gz
       
    38 COMPONENT_ARCHIVE_URL=	https://storage.googleapis.com/golang/$(COMPONENT_ARCHIVE)
       
    39 COMPONENT_ARCHIVE_HASH=	 \
       
    40 	sha256:72680c16ba0891fcf2ccf46d0f809e4ecf47bbf889f5d884ccb54c5e9a17e1c0
       
    41 COMPONENT_PROJECT_URL=	https://golang.org
       
    42 
       
    43 ARC_CASE=		PSARC/2015/203,PSARC/2016/250
       
    44 TPNO=			23679,29538
       
    45 
       
    46 # Go has a number of supplementary tools and packages that are located in
       
    47 # separate archives or source repositories. Because Go currently forces a
       
    48 # recompile of all packages whenever the compiler changes, building and
       
    49 # delivering them within the same build component build process is the best
       
    50 # option for now.
       
    51 
       
    52 # Supplementary packages; these are delivered as source only for now as the
       
    53 # paths to the compiled packages are written directly into the binaries and
       
    54 # there's no way (currently) to fix that during the build process.
       
    55 SUPP_PACKAGES=		crypto image lint net sys text tools tour
       
    56 
       
    57 define supp-rules
       
    58 COMPONENT_NAME_$(1)=		$(1)
       
    59 COMPONENT_VERSION_$(1)=		$(COMPONENT_VERSION)
       
    60 COMPONENT_LABEL_$(1)=
       
    61 COMPONENT_IMPORT_SRC_$(1)=	golang.org/x
       
    62 GIT_REPO_$(1)=			https://github.com/golang/$(1).git
       
    63 TPNO_$(1)=			$(TPNO)
       
    64 endef
       
    65 
       
    66 $(foreach suffix, $(SUPP_PACKAGES), $(eval $(call supp-rules,$(suffix))))
       
    67 
       
    68 # Desired "revision" of Go's "community" libraries; these are arbitrary
       
    69 # revisions chosen from the last commit to the respective repository at the
       
    70 # same time that this component was updated as there is no formal release
       
    71 # process for these packages.  Whenever Go is updated, these should be as well.
       
    72 GIT_COMMIT_ID_crypto=		986d3313588aa5c68f1df95eac956f79cf3b2c01
       
    73 GIT_COMMIT_ID_image=		9f8d0d45877da31f672995d10677ae6a586e31a5
       
    74 GIT_COMMIT_ID_lint=		c7bacac2b21ca01afa1dee0acf64df3ce047c28f
       
    75 GIT_COMMIT_ID_net=		7394c112eae4dba7e96bfcfe738e6373d61772b4
       
    76 GIT_COMMIT_ID_sys=		9bb9f0998d48b31547d975974935ae9b48c7a03c
       
    77 GIT_COMMIT_ID_text=		d69c40b4be55797923cec7457fac7a244d91a9b6
       
    78 GIT_COMMIT_ID_tools=		5cb1c80a83ef2a98bbc7b2fba1305239bb684fbe
       
    79 GIT_COMMIT_ID_tour=		c9941e54e5b8e9618a8c951bc89798f85f6a7a71
       
    80 
       
    81 # Resulting hash of related git commit once archived.
       
    82 GIT_HASH_crypto=  sha256:62a83544383df032f63d655c6831316da80de93b1a3d99593950b32f40a823a3
       
    83 GIT_HASH_image=  sha256:979c3a8fb093508c27b95dff99b42a3a1fbd0e83374f40097608dd637b9f6968
       
    84 GIT_HASH_lint=  sha256:6f9d91eaa133f7dad2bb65a901b972e952c1acc9e7e504e5efe0605000369305
       
    85 GIT_HASH_net=  sha256:e568aee2b95f9eb375a213ed80020a5ce133767b93723bba037f9a99071e7d32
       
    86 GIT_HASH_sys=  sha256:dd44f9fc2d78bc69eec53dd9bfcdf6740fbb5bd2ad4a75ad11d62f5b4bd62afd
       
    87 GIT_HASH_text=  sha256:397ab7c85efc9272de036ebdebfe91ca6ac190765d883950845dec6a189769bc
       
    88 GIT_HASH_tools=  sha256:0d386842aea4abf61d1d5eff7795ee01ec3d6a49353fccb477c53330f42245e3
       
    89 GIT_HASH_tour=  sha256:b9f64fa35ca745b1841502e7aa880c7cadbadcb07c657239d58b5e31da55f170
       
    90 
       
    91 # Go package imports for lint are found in github directory.
       
    92 COMPONENT_IMPORT_SRC_lint=	github.com/golang
       
    93 
       
    94 # Go's "not well-formed" elf objects confuse elfsign, which then causes
       
    95 # problems for RE.  For now, we workaround this by adding the
       
    96 # 'com.oracle.elfsign=false' tag to every elf object.
       
    97 NO_ELFSIGN_MOG=		$(BUILD_DIR)/no-elfsign.mog
       
    98 
       
    99 PUBLISH_STAMP= $(NO_ELFSIGN_MOG) $(BUILD_DIR)/.published-$(MACH)
       
   100 
       
   101 # Bake in where Go package will be installed.
       
   102 GOROOT_FINAL=		/usr/lib/golang/$(COMPONENT_MAJOR_VERSION)
       
   103 # Enable easier stack unwinding for debugging.
       
   104 GOEXPERIMENT=		framepointer
       
   105 COMPONENT_BUILD_ENV +=	GOROOT_FINAL="$(GOROOT_FINAL)"
       
   106 COMPONENT_BUILD_ENV +=	GOEXPERIMENT="$(GOEXPERIMENT)"
       
   107 
       
   108 # This allows us to build regardless of whether 1.5 or 1.7 is installed.
       
   109 BOOTSTRAP= $(firstword $(wildcard $(USRLIBDIR)/golang/1.[57]))
       
   110 COMPONENT_BUILD_ENV +=	\
       
   111 	GOROOT_BOOTSTRAP="$(BOOTSTRAP)"
       
   112 
       
   113 # Install root for supplementary packages.
       
   114 SUPP_ROOT=$(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)
       
   115 
       
   116 # For convenience during installation of supplementary packages.
       
   117 COMPONENT_INSTALL_ENV += PATH="$(PROTO_DIR)$(GOROOT_FINAL)/bin:$(PATH)"
       
   118 COMPONENT_INSTALL_ENV += GOROOT="$(PROTO_DIR)$(GOROOT_FINAL)"
       
   119 COMPONENT_INSTALL_ENV += GOPATH="$(SUPP_ROOT)"
       
   120 
       
   121 BUILD_STYLE= justmake
       
   122 BUILD_64 += $(BUILD_DIR)/man1/go.1
       
   123 INSTALL_64 := build $(INSTALL_64)
       
   124 ifeq ($(MACH), sparc)
       
   125 # At least one test in the suite core dumps on sparc64; skip until ready.
       
   126 TEST_TARGET= $(SKIP_TESTS)
       
   127 endif
       
   128 include $(WS_MAKE_RULES)/common.mk
       
   129 
       
   130 # Simplify source copying for install by eliding patch detritus.
       
   131 GPATCH_BACKUP=
       
   132 
       
   133 # Enable local transforms.
       
   134 PKG_OPTIONS += -I $(COMPONENT_DIR)
       
   135 
       
   136 # Avoid some of the default transforms:
       
   137 # - facet.devel serves no useful purpose for a development package
       
   138 # - facet.doc wrongly assumes all things in a doc directory are documentation;
       
   139 #   in Go's case, some are binaries
       
   140 #
       
   141 # This requires completely redefining PUBLISH_TRANSFORMS for now.
       
   142 PUBLISH_TRANSFORMS=	$(LICENSE_TRANSFORMS)
       
   143 PUBLISH_TRANSFORMS +=	$(WS_TOP)/transforms/variant-cleanup
       
   144 PUBLISH_TRANSFORMS +=	$(WS_TOP)/transforms/defaults
       
   145 PUBLISH_TRANSFORMS +=	$(WS_TOP)/transforms/actuators
       
   146 PUBLISH_TRANSFORMS +=	$(WS_TOP)/transforms/locale
       
   147 PUBLISH_TRANSFORMS +=	$(PKGMOGRIFY_TRANSFORMS)
       
   148 PUBLISH_TRANSFORMS +=	$(WS_TOP)/transforms/incorporate
       
   149 PUBLISH_TRANSFORMS +=	$(WS_TOP)/transforms/publish-cleanup
       
   150 ifeq ($(BUILD_TYPE),evaluation)
       
   151 	PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/evaluation
       
   152 endif
       
   153 
       
   154 $(NO_ELFSIGN_MOG): install
       
   155 	cd $(PROTO_DIR); \
       
   156 	find . -type f -exec elffile {} + | grep 'ELF [36]' | \
       
   157 	    $(GSED) -e 's/^..\(.*\):.*$$/<transform file path=\1$$ -> \\\
       
   158 	        default com.oracle.elfsign false>/' > $@
       
   159 
       
   160 PUBLISH_TRANSFORMS +=	$(NO_ELFSIGN_MOG)
       
   161 
       
   162 # Building go from the source repository version requires that we set an
       
   163 # effective version and add some sort of unique identifier (in the case of
       
   164 # pre-release versions), so we use 'devel' + archive hash + date similar to how
       
   165 # Go internally determines one normally from git revision info.  Use the block
       
   166 # below when building from the upstream source repository or when building a
       
   167 # development version from a source tarball:
       
   168 #
       
   169 # We have to fiddle with the package archives to get them into the same source
       
   170 # directory so that we can use the standard build targets.  We're effectively
       
   171 # building multiple components using a single target.
       
   172 COMPONENT_POST_UNPACK_ACTION= \
       
   173 	$(MV) go $(COMPONENT_SRC) && \
       
   174 	$(TOUCH) $(COMPONENT_SRC)/VERSION && \
       
   175 	echo "devel $(shell digest -a md5 $(COMPONENT_ARCHIVE)) \
       
   176 		$(shell date -u +'%a %b %e %T %Z %Y')" > \
       
   177 		$(COMPONENT_SRC)/VERSION && \
       
   178 	(cd $(COMPONENT_SRC); git apply -p1 < ../patches/*.git)
       
   179 
       
   180 # Go doesn't have a standard Makefile-based build process, so override the
       
   181 # default.
       
   182 COMPONENT_BUILD_ACTION=	\
       
   183 	cd $(@D)/src; $(ENV) $(COMPONENT_BUILD_ENV) ./make.bash
       
   184 
       
   185 COMPONENT_TARGET_DIR= \
       
   186 	$(PROTOUSRLIBDIR)/$(COMPONENT_NAME)/$(COMPONENT_MAJOR_VERSION)
       
   187 
       
   188 # We can't do any ASLR'ing as the Go 6l linker has no understanding of the
       
   189 # -z aslr=... option. So just override where needed in the .p5m files.
       
   190 ASLR_MODE = $(ASLR_DISABLE)
       
   191 
       
   192 # The timestamp is generated immediately once when the Makefile is evaluated to
       
   193 # ensure every package gets the same one.
       
   194 GOTS := $(shell date +"%Y%m%dT%H%M%SZ")
       
   195 
       
   196 # Make sure the source code and object files have identical timestamps so
       
   197 # the Go compiler doesn't try to rebuild them.
       
   198 PKG_MACROS += TIMESTAMP=$(GOTS)
       
   199 # Extra macros for packaging convenience.
       
   200 PKG_MACROS += COMPONENT_MAJOR_VERSION=$(COMPONENT_MAJOR_VERSION)
       
   201 # Compound version of major version (e.g. 1.5 -> 15).
       
   202 PKG_MACROS += COMPONENT_CMAJOR_VERSION=$(subst .,,$(COMPONENT_MAJOR_VERSION))
       
   203 # COMPONENT_MAJOR_VERSION suitable for use in regular expressions.
       
   204 PKG_MACROS += COMPONENT_RE_MAJOR_VERSION=$(subst .,\\.,$(COMPONENT_MAJOR_VERSION))
       
   205 # GOMACH64 is Go's name for current build architecture
       
   206 PKG_MACROS += GOMACH64=$(MACH64:sparcv9=sparc64)
       
   207 
       
   208 COMPONENT_TEST_ENV +=	PATH="$(@D)/bin:$(PATH)"
       
   209 COMPONENT_TEST_ENV +=	GOROOT="$(@D)"
       
   210 COMPONENT_TEST_DIR=	$(@D)/src
       
   211 COMPONENT_TEST_CMD=	./run.bash
       
   212 COMPONENT_TEST_TARGETS=
       
   213 
       
   214 # Go's test suite does not have deterministic output or order, and as such,
       
   215 # success can only be determined by exit code, not by output comparison.
       
   216 COMPONENT_TEST_CREATE_TRANSFORMS=
       
   217 COMPONENT_TEST_PERFORM_TRANSFORM=
       
   218 COMPONENT_TEST_COMPARE=
       
   219 
       
   220 XML2ROFF= $(USRSHAREDIR)/xml/xsolbook/python/xml2roff.py
       
   221 
       
   222 $(BUILD_DIR)/man1/go.1:
       
   223 	$(XML2ROFF) $(COMPONENT_DIR)/docs/go.1 -o $(BUILD_DIR)
       
   224 
       
   225 define COMPONENT_INSTALL_ACTION=
       
   226 	($(MKDIR) $(COMPONENT_TARGET_DIR)/src); \
       
   227 	(cd $(SOURCE_DIR) && \
       
   228 	$(GNUBIN)/find . -maxdepth 1 -print \
       
   229 	  -exec $(GNUBIN)/cp -r \
       
   230 	  --parents {} $(COMPONENT_TARGET_DIR) \;); \
       
   231 	(cd $(BUILD_DIR_64) && \
       
   232 	$(GNUBIN)/find src -type f \
       
   233 		-exec $(GNUBIN)/cp --parents {} $(COMPONENT_TARGET_DIR) \;); \
       
   234 	(cd $(BUILD_DIR_64) && $(CP) -r bin $(COMPONENT_TARGET_DIR)/); \
       
   235 	(cd $(BUILD_DIR_64) && $(CP) -r pkg $(COMPONENT_TARGET_DIR)/); \
       
   236 	($(MKDIR) $(PROTOUSRSHAREDIR)/golang); \
       
   237 	($(CP) $(BUILD_DIR)/man1/go.1 $(PROTOUSRSHAREDIR)/golang/go-$(COMPONENT_MAJOR_VERSION).1); \
       
   238 	($(RM) $(NO_ELFSIGN_MOG))
       
   239 endef
       
   240 
       
   241 # clear COMPONENT_POST_INSTALL_ACTION so we can append PERL_SCRIPTS_PROCESS
       
   242 # at the end
       
   243 COMPONENT_POST_INSTALL_ACTION =
       
   244 
       
   245 #
       
   246 # Magic to deliver supplemental package source into proto area.
       
   247 #
       
   248 define install-rules
       
   249 $(MANIFEST_BASE)-$(1)-17.mogrified: PKG_PROTO_DIRS= $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC_$(1))
       
   250 
       
   251 BUILD_64 += $$(UNPACK_STAMP_$(1))
       
   252 
       
   253 COMPONENT_POST_INSTALL_ACTION += \
       
   254 	($(MKDIR) \
       
   255 		$(SUPP_ROOT)/src/$$(COMPONENT_IMPORT_SRC_$(1))/$$(COMPONENT_NAME_$(1)); \
       
   256 	$(CP) -r $$(COMPONENT_SRC_$(1))/* \
       
   257 		$(SUPP_ROOT)/src/$$(COMPONENT_IMPORT_SRC_$(1))/$$(COMPONENT_NAME_$(1)));
       
   258 
       
   259 endef
       
   260 
       
   261 $(foreach suffix,$(SUPP_PACKAGES), $(eval $(call install-rules,$(suffix))))
       
   262 # Install supplementary packages (this cannot be done one-by-one); install
       
   263 # tools/go/types first to avoid quirk with trimpath and dependencies.  This is
       
   264 # technically a build and install, but go's build command won't "install"
       
   265 # results, it only verifies a target can be built and dumps it into a temporary
       
   266 # directory.
       
   267 #
       
   268 # The -trimpath option used here ensures that the paths recorded in the
       
   269 # pre-built packages do not contain the containing directory; the result is a
       
   270 # path that Go will evaluate relative to $GOPATH and so will pass the "stale"
       
   271 # object checks that Go performs at build time allowing reuse of the pre-built
       
   272 # packages.
       
   273 PROTO_ROOT= $(SUPP_ROOT)
       
   274 COMPONENT_POST_INSTALL_ACTION += \
       
   275 	($(ENV) $(COMPONENT_INSTALL_ENV) go install \
       
   276 		-asmflags -trimpath=$(PROTO_ROOT) -gcflags -trimpath=$(PROTO_ROOT) \
       
   277 		"golang.org/x/tools/go/types"; \
       
   278 	$(ENV) $(COMPONENT_INSTALL_ENV) go install \
       
   279 		-asmflags -trimpath=$(PROTO_ROOT) -gcflags -trimpath=$(PROTO_ROOT) \
       
   280 		"golang.org/x/..."; \
       
   281 	$(ENV) $(COMPONENT_INSTALL_ENV) go install \
       
   282 		-asmflags -trimpath=$(PROTO_ROOT) -gcflags -trimpath=$(PROTO_ROOT) \
       
   283 		"github.com/golang/...");
       
   284 
       
   285 PERL_SCRIPTS= \
       
   286   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/plan9/mksyscall.pl \
       
   287   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksyscall.pl \
       
   288   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksyscall_solaris.pl \
       
   289   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksysctl_openbsd.pl \
       
   290   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksysnum_darwin.pl \
       
   291   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksysnum_dragonfly.pl \
       
   292   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksysnum_freebsd.pl \
       
   293   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksysnum_linux.pl \
       
   294   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksysnum_netbsd.pl \
       
   295   $(PROTOUSRLIBDIR)/gocode/$(COMPONENT_MAJOR_VERSION)/src/golang.org/x/sys/unix/mksysnum_openbsd.pl \
       
   296   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/net/http/cgi/testdata/test.cgi \
       
   297   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/regexp/syntax/make_perl_groups.pl \
       
   298   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksyscall.pl \
       
   299   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksyscall_solaris.pl \
       
   300   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksysctl_openbsd.pl \
       
   301   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksysnum_darwin.pl \
       
   302   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksysnum_dragonfly.pl \
       
   303   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksysnum_freebsd.pl \
       
   304   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksysnum_linux.pl \
       
   305   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksysnum_netbsd.pl \
       
   306   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/src/syscall/mksysnum_openbsd.pl \
       
   307   $(PROTOUSRLIBDIR)/golang/$(COMPONENT_MAJOR_VERSION)/test/errchk
       
   308 
       
   309 COMPONENT_POST_INSTALL_ACTION += $(PERL_SCRIPTS_PROCESS)
       
   310 
       
   311 # Go's test suite is currently designed to be run from the build area.
       
   312 
       
   313 # Used during the build.
       
   314 REQUIRED_PACKAGES += developer/gcc
       
   315 REQUIRED_PACKAGES += developer/versioning/git
       
   316 ifneq ($(MACH), sparc)
       
   317 # Go bootstraps itself using Go, so at least one previous version must already
       
   318 # be installed.
       
   319 REQUIRED_PACKAGES += developer/golang
       
   320 endif
       
   321 # Used in this Makefile.
       
   322 REQUIRED_PACKAGES += file/gnu-findutils
       
   323 REQUIRED_PACKAGES += text/gnu-sed
       
   324 # Required to build man pages.
       
   325 REQUIRED_PACKAGES += developer/documentation-tool/xml2roff
       
   326 # There's a single test script which requires perl.
       
   327 REQUIRED_PACKAGES += $(PERL_PKG)
       
   328 REQUIRED_PACKAGES += system/header
       
   329 REQUIRED_PACKAGES += system/library
       
   330 # Used for cgo support at runtime; we don't add a package dependency since cgo
       
   331 # support is optional.
       
   332 REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime
       
   333 REQUIRED_PACKAGES += system/linker