Skip to content

Commit 14adb55

Browse files
authored
Makefile refactoring to factor out common build code (#2672)
* Don't use double brackets in source script Match the same style as used in the rest of the script. I observed a syntax error when running in a Docker container locally as well, so fix this up quickly. * Move arch and uarch specific code out of main Makefile Following on from pull request #2614, we want to make it easier to distinguish common and platform specific code when building. We take common code from the main makefile, and split this out into arch and uarch specific files. We try and share as much code as possible between uarch files. In this first commit, we make sure that the x86 build works on linux. Next commits will make sure that the Mac, Windows and Arm builds also work. For now these are broken. * Update Mac, Windows and Arm makefile configuration Put Mac and Windows makefile code into their own files, and correct some copy-paste errors in the Arm build. This should build on all platforms now, but there are some more commits to go on top before the refactor is done. * Refactor compiler configuration in makefiles We want to have as much common code shared between makefiles for different compilers, as well as for the different backends. We shuffle things around a little. This now passes on x86 Linux as well as aarch64. Needs some internal tests to be run. * Remove recursive definition * Code review copyright notice and new line changes * Remove year from contributors copyright notice * Don't use year in copyright * review comments
1 parent fcc8d3b commit 14adb55

24 files changed

+498
-311
lines changed

deploy/local/vars_lnx.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ fi
226226

227227
ARCH_ONEDAL=$(uname -m)
228228

229-
if [[ "${ARCH_ONEDAL}" == "x86_64" ]]; then
229+
if [ "${ARCH_ONEDAL}" = "x86_64" ]; then
230230
ARCH_DIR_ONEDAL="intel64"
231-
elif [[ "${ARCH_ONEDAL}" == "aarch64" ]]; then
231+
elif [ "${ARCH_ONEDAL}" = "aarch64" ]; then
232232
ARCH_DIR_ONEDAL="arm"
233233
else
234234
echo "Unsupported CPU architecture '${ARCH_ONEDAL}'"

dev/make/common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ secure.opts.link.mac =
7878

7979
RC.COMPILE = rc.exe $(RCOPT) -fo$@ $<
8080

81+
# Used as $(eval $(call set_c_compile,$(COMPILER),$(_OS),$(gcc_toolchain))
8182
C.COMPILE = $(if $(COMPILER.$(_OS).$(COMPILER)),$(COMPILER.$(_OS).$(COMPILER)),$(error COMPILER.$(_OS).$(COMPILER) must be defined)) \
8283
$(if $(C.COMPILE.gcc_toolchain),--gcc-toolchain=$(C.COMPILE.gcc_toolchain)) \
8384
-c $(secure.opts.icc.$(_OS)) $(COPT) $(INCLUDES) $1 $(-Fo)$@ $<

dev/make/cmplr.clang.mkl.32e.mk renamed to dev/make/compiler_definitions/clang.32e.mk

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# file: cmplt.clang.mk
1+
# file: clang.32e.mk
22
#===============================================================================
33
# Copyright 2012 Intel Corporation
44
#
@@ -16,17 +16,15 @@
1616
#===============================================================================
1717

1818
#++
19-
# Clang definitions for makefile
19+
# Clang definitions for makefile.
20+
# This file contains definitions common to clang on a 32e (intel64) platform.
21+
# It should only be included from files which have more specializations (e.g.
22+
# clang.mkl.32e.mk)
2023
#--
2124

22-
PLATs.clang = lnx32e mac32e
23-
24-
CMPLRDIRSUFF.clang = _clang
25-
26-
CORE.SERV.COMPILER.clang = generic
25+
include dev/make/compiler_definitions/clang.mk
2726

28-
-Zl.clang =
29-
-DEBC.clang = -g
27+
PLATs.clang = lnx32e mac32e
3028

3129
COMPILER.mac.clang = clang++ -m64 -fgnu-runtime -stdlib=libc++ -mmacosx-version-min=10.15 -fwrapv \
3230
-Werror -Wreturn-type
@@ -36,11 +34,6 @@ COMPILER.lnx.clang = clang++ -m64 \
3634
link.dynamic.mac.clang = clang++ -m64
3735
link.dynamic.lnx.clang = clang++ -m64
3836

39-
pedantic.opts.clang = -pedantic \
40-
-Wall \
41-
-Wextra \
42-
-Wno-unused-parameter
43-
4437
pedantic.opts.mac.clang = $(pedantic.opts.clang)
4538
pedantic.opts.lnx.clang = $(pedantic.opts.clang)
4639

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# file: cmplt.clang.mk
1+
# file: clang.mk
22
#===============================================================================
3-
# Copyright 2023 Intel Corporation
3+
# Copyright contributors to the oneDAL project
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -17,34 +17,19 @@
1717

1818
#++
1919
# Clang definitions for makefile
20+
# This file contains definitions common to clang on all platforms.
21+
# It should only be included from files which have more specializations (e.g.
22+
# clang.32e.mk)
2023
#--
2124

22-
PLATs.clang = lnx32e mac32e
23-
2425
CMPLRDIRSUFF.clang = _clang
2526

2627
CORE.SERV.COMPILER.clang = generic
2728

2829
-Zl.clang =
2930
-DEBC.clang = -g
3031

31-
COMPILER.mac.clang = clang++ -m64 -fgnu-runtime -stdlib=libc++ -mmacosx-version-min=10.15 -fwrapv \
32-
-DDAAL_REF -DONEDAL_REF -Werror -Wreturn-type
33-
COMPILER.lnx.clang = clang++ -m64 \
34-
-DDAAL_REF -DONEDAL_REF -Werror -Wreturn-type
35-
36-
link.dynamic.mac.clang = clang++ -m64
37-
link.dynamic.lnx.clang = clang++ -m64
38-
3932
pedantic.opts.clang = -pedantic \
4033
-Wall \
4134
-Wextra \
4235
-Wno-unused-parameter
43-
44-
pedantic.opts.mac.clang = $(pedantic.opts.clang)
45-
pedantic.opts.lnx.clang = $(pedantic.opts.clang)
46-
47-
p4_OPT.clang = $(-Q)march=nocona
48-
mc3_OPT.clang = $(-Q)$(if $(OS_is_mac),march=nocona,march=nehalem) $(if $(OS_is_mac),$(-Q)mtune=nehalem)
49-
avx2_OPT.clang = $(-Q)march=haswell
50-
skx_OPT.clang = $(-Q)march=skx
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# file: clang.mkl.32e.mk
2+
#===============================================================================
3+
# Copyright 2012 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#===============================================================================
17+
18+
#++
19+
# Clang definitions for makefile
20+
#--
21+
22+
include dev/make/compiler_definitions/clang.32e.mk
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# file: clang.ref.32e.mk
2+
#===============================================================================
3+
# Copyright contributors to the oneDAL project
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#===============================================================================
17+
18+
#++
19+
# Clang definitions for makefile
20+
#--
21+
22+
include dev/make/compiler_definitions/clang.32e.mk
23+
24+
COMPILER.mac.clang = $(COMPILER.mac.clang) -DDAAL_REF -DONEDAL_REF
25+
COMPILER.lnx.clang = $(COMPILER.lnx.clang) -DDAAL_REF -DONEDAL_REF

dev/make/cmplr.clang.ref.arm.mk renamed to dev/make/compiler_definitions/clang.ref.arm.mk

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# file: cmplr.clang.ref.arm.mk
1+
# file: clang.ref.arm.mk
22
#===============================================================================
33
# Copyright contributors to the oneDAL project
44
#
@@ -19,26 +19,15 @@
1919
# Clang definitions for makefile
2020
#--
2121

22-
PLATs.clang = lnxarm
23-
24-
CMPLRDIRSUFF.clang = _clang
25-
26-
CORE.SERV.COMPILER.clang = generic
22+
include dev/make/compiler_definitions/clang.mk
2723

28-
-Zl.clang =
29-
-DEBC.clang = -g
24+
PLATs.clang = lnxarm
3025

3126
COMPILER.lnx.clang= clang++ -march=armv8-a+sve \
3227
-DDAAL_REF -DONEDAL_REF -DDAAL_CPU=sve -Werror -Wreturn-type
3328
# Linker flags
3429
link.dynamic.lnx.clang = clang++ -march=armv8-a+sve
3530

36-
pedantic.opts.clang = -pedantic \
37-
-Wall \
38-
-Wextra \
39-
-Wno-unused-parameter
40-
41-
pedantic.opts.mac.clang = $(pedantic.opts.clang)
4231
pedantic.opts.lnx.clang = $(pedantic.opts.clang)
4332

4433
# For SVE
File renamed without changes.

dev/make/cmplr.gnu.mkl.32e.mk renamed to dev/make/compiler_definitions/gnu.32e.mk

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#===============================================================================
2-
# Copyright 2023 Intel Corporation
2+
# Copyright contributors to the oneDAL project
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -16,34 +16,25 @@
1616

1717
#++
1818
# g++ definitions for makefile
19+
# This file contains definitions common to gnu on a 32e (intel64) platform. It
20+
# should only be included from files which have more specializations (e.g.
21+
# gnu.mkl.32e.mk)
1922
#--
2023

21-
PLATs.gnu = lnx32e mac32e
22-
23-
CMPLRDIRSUFF.gnu = _gnu
24-
25-
CORE.SERV.COMPILER.gnu = generic
24+
include dev/make/compiler_definitions/gnu.mk
2625

27-
-Zl.gnu =
28-
-DEBC.gnu = -g
26+
PLATs.gnu = lnx32e mac32e
2927

3028
COMPILER.all.gnu = ${CXX} -m64 -fwrapv -fno-strict-overflow -fno-delete-null-pointer-checks \
3129
-Werror -Wreturn-type
3230

3331
link.dynamic.all.gnu = ${CXX} -m64
3432

35-
pedantic.opts.all.gnu = -pedantic \
36-
-Wall \
37-
-Wextra \
38-
-Wno-unused-parameter
39-
40-
COMPILER.lnx.gnu = $(COMPILER.all.gnu)
41-
link.dynamic.lnx.gnu = $(link.dynamic.all.gnu)
4233
pedantic.opts.lnx.gnu = $(pedantic.opts.all.gnu)
34+
pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu)
4335

44-
COMPILER.mac.gnu = $(COMPILER.all.gnu)
36+
link.dynamic.lnx.gnu = $(link.dynamic.all.gnu)
4537
link.dynamic.mac.gnu = $(link.dynamic.all.gnu)
46-
pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu)
4738

4839
p4_OPT.gnu = $(-Q)march=nocona
4940
mc3_OPT.gnu = $(-Q)march=corei7
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#===============================================================================
2-
# Copyright 2023 Intel Corporation
2+
# Copyright contributors to the oneDAL project
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -16,36 +16,19 @@
1616

1717
#++
1818
# g++ definitions for makefile
19+
# This file contains definitions common to gnu on all platforms. It
20+
# should only be included from files which have more specializations (e.g.
21+
# gnu.32e.mk)
1922
#--
2023

21-
PLATs.gnu = lnx32e mac32e
22-
2324
CMPLRDIRSUFF.gnu = _gnu
2425

2526
CORE.SERV.COMPILER.gnu = generic
2627

2728
-Zl.gnu =
2829
-DEBC.gnu = -g
2930

30-
COMPILER.all.gnu = ${CXX} -m64 -fwrapv -fno-strict-overflow -fno-delete-null-pointer-checks \
31-
-DDAAL_REF -DONEDAL_REF -Werror -Wreturn-type
32-
33-
link.dynamic.all.gnu = ${CXX} -m64
34-
3531
pedantic.opts.all.gnu = -pedantic \
3632
-Wall \
3733
-Wextra \
3834
-Wno-unused-parameter
39-
40-
COMPILER.lnx.gnu = $(COMPILER.all.gnu)
41-
link.dynamic.lnx.gnu = $(link.dynamic.all.gnu)
42-
pedantic.opts.lnx.gnu = $(pedantic.opts.all.gnu)
43-
44-
COMPILER.mac.gnu = $(COMPILER.all.gnu)
45-
link.dynamic.mac.gnu = $(link.dynamic.all.gnu)
46-
pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu)
47-
48-
p4_OPT.gnu = $(-Q)march=nocona
49-
mc3_OPT.gnu = $(-Q)march=corei7
50-
avx2_OPT.gnu = $(-Q)march=haswell
51-
skx_OPT.gnu = $(-Q)march=skylake
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#===============================================================================
2+
# Copyright 2023 Intel Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#===============================================================================
16+
17+
#++
18+
# g++ definitions for makefile
19+
#--
20+
21+
include dev/make/compiler_definitions/gnu.32e.mk
22+
23+
COMPILER.lnx.gnu = $(COMPILER.all.gnu)
24+
COMPILER.mac.gnu = $(COMPILER.all.gnu)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#===============================================================================
2+
# Copyright 2023 Intel Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#===============================================================================
16+
17+
#++
18+
# g++ definitions for makefile
19+
#--
20+
21+
include dev/make/compiler_definitions/gnu.32e.mk
22+
23+
COMPILER.lnx.gnu = $(COMPILER.all.gnu) -DDAAL_REF -DONEDAL_REF
24+
COMPILER.mac.gnu = $(COMPILER.all.gnu) -DDAAL_REF -DONEDAL_REF

dev/make/cmplr.gnu.ref.arm.mk renamed to dev/make/compiler_definitions/gnu.ref.arm.mk

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,17 @@
1818
# g++ definitions for makefile
1919
#--
2020

21-
PLATs.gnu = lnxarm
22-
23-
CMPLRDIRSUFF.gnu = _gnu
24-
25-
CORE.SERV.COMPILER.gnu = generic
21+
include dev/make/compiler_definitions/gnu.mk
2622

27-
-Zl.gnu =
28-
-DEBC.gnu = -g
23+
PLATs.gnu = lnxarm
2924

3025
COMPILER.all.gnu = ${CXX} -march=armv8-a+sve -fwrapv -fno-strict-overflow -fno-delete-null-pointer-checks \
3126
-DDAAL_REF -DONEDAL_REF -DDAAL_CPU=sve -Werror -Wreturn-type
3227

3328
link.dynamic.all.gnu = ${CXX} -march=native
3429

35-
pedantic.opts.all.gnu = -pedantic \
36-
-Wall \
37-
-Wextra \
38-
-Wno-unused-parameter
39-
4030
COMPILER.lnx.gnu = $(COMPILER.all.gnu)
4131
link.dynamic.lnx.gnu = $(link.dynamic.all.gnu)
4232
pedantic.opts.lnx.gnu = $(pedantic.opts.all.gnu)
4333

44-
COMPILER.mac.gnu = $(COMPILER.all.gnu)
45-
link.dynamic.mac.gnu = $(link.dynamic.all.gnu)
46-
pedantic.opts.mac.gnu = $(pedantic.opts.all.gnu)
47-
4834
a8sve_OPT.gnu = $(-Q)march=armv8-a+sve

0 commit comments

Comments
 (0)