Skip to content

Commit

Permalink
Build controls for AIX with xlclang and openxl toolchains
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcw authored and grafikrobot committed Nov 13, 2024
1 parent 936cf31 commit 276452f
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/engine/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ You can specify the toolset as the argument, i.e.:
Toolsets supported by this script are:
acc, clang, como, gcc, intel-darwin, intel-linux, kcc, kylix, mipspro,
pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp
pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp, xlclang, openxl
For any toolset you can override the path to the compiler with the '--cxx'
option. You can also use additional flags for the compiler with the
Expand Down Expand Up @@ -156,6 +156,11 @@ check_toolset ()

# Prefer Clang (clang) on macOS..
if test_toolset clang && test_uname Darwin && test_compiler clang++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=clang$TOOLSET_SUFFIX ; return ${TRUE} ; fi
# Prefer IBMClang (ibm-clang_r) on AIX if present
if test_toolset openxl && test_uname AIX && test_compiler ibm-clang++_r$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=openxl$TOOLSET_SUFFIX ; return ${TRUE} ; fi
# Then prefer XLClang (xlclang) on AIX
if test_toolset xlclang && test_uname AIX && test_compiler xlclang++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=xlclang$TOOLSET_SUFFIX ; return ${TRUE} ; fi

# GCC (gcc) with -pthread arg (for AIX and others)..
if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 -pthread ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi
# GCC (gcc)..
Expand Down Expand Up @@ -413,6 +418,18 @@ case "${B2_TOOLSET}" in
B2_CXXFLAGS_DEBUG="O0 -Wc,-fno-inline -gstabs+"
;;

xlclang)
CXX_VERSION_OPT=-qversion
B2_CXXFLAGS_RELEASE="-O3 -s -qstrict -qinline"
B2_CXXFLAGS_DEBUG="-g -O0 -qnoinline -pg"
;;

openxl)
CXX_VERSION_OPT=--version
B2_CXXFLAGS_RELEASE="-O3 -Wl,-s"
B2_CXXFLAGS_DEBUG="-g -O0"
;;

cxx)
CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
;;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/common.jam
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ local rule toolset-tag ( name : type ? : property-set )
case sun* : tag += sw ;
case tru64cxx* : tag += tru ;
case vacpp* : tag += xlc ;
case xlclang* : tag += xlclang ;
case openxl* : tag += openxl ;
}
local version = [ MATCH "<toolset.*version>([0123456789]+)[.]?([0123456789]*)"
: $(properties) ] ;
Expand Down
161 changes: 161 additions & 0 deletions src/tools/openxl.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Copyright Vladimir Prus 2004.
# Copyright Toon Knapen 2004.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt
# or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)

#| tag::doc[]

[[bbv2.reference.tools.compiler.openxl]]
= IBM Visual Age

The `openxl` module supports the http://www.ibm.com/software/ad/openxl[IBM
Visual Age] C++ Compiler, for the AIX operating system. Versions 7.1 and
8.0 are known to work.

The module is initialized using the following syntax:

----
using openxl ;
----

The module does not accept any initialization options. The compiler
should be installed in the `/usr/openxl/bin` directory.

Later versions of Visual Age are known as XL C/C++. They were not tested
with the the `openxl` module.

|# # end::doc[]

#
# B2 V2 toolset for the IBM XL C++ compiler
#

import toolset : flags ;
import feature ;
import common ;
import generators ;
import os ;

feature.extend toolset : openxl ;
toolset.inherit openxl : unix ;
generators.override openxl.prebuilt : builtin.prebuilt ;
generators.override openxl.searched-lib-generator : searched-lib-generator ;

# Configure the openxl toolset
rule init ( version ? : command * : options * )
{
local condition = [
common.check-init-parameters openxl : version $(version) ] ;

command = [ common.get-invocation-command openxl : ibm-clang++_r
: $(command) : "/opt/IBM/openxlC/17.1.0/bin/ibm-clang++_r" ] ;

common.handle-options openxl : $(condition) : $(command) : $(options) ;
}

# Declare generators
generators.register-c-compiler openxl.compile.c : C : OBJ : <toolset>openxl ;
generators.register-c-compiler openxl.compile.c++ : CPP : OBJ : <toolset>openxl ;

# Declare flags
flags openxl CFLAGS <optimization>speed : -O3 ;
flags openxl CFLAGS <optimization>space : -O2 -Os ;

# Discretionary inlining (not recommended)
flags openxl CFLAGS <inlining>off : -fno-inline-functions ;
flags openxl CFLAGS <inlining>on : ;
#flags openxl CFLAGS <inlining>full : -qinline ;
flags openxl CFLAGS <inlining>full : ;

# Exception handling
flags openxl C++FLAGS <exception-handling>off : -fno-exceptions ;
flags openxl C++FLAGS <exception-handling>on : ;

# Run-time Type Identification
flags openxl C++FLAGS <rtti>off : -fno-rtti ;
flags openxl C++FLAGS <rtti>on : ;

# Enable 64-bit memory addressing model
flags openxl CFLAGS <address-model>64 : -m64 ;
flags openxl LINKFLAGS <address-model>64 : -m64 ;
flags openxl ARFLAGS <target-os>aix/<address-model>64 : -X 64 ;

# Use absolute path when generating debug information
flags openxl CFLAGS <debug-symbols>on : -g ;
flags openxl LINKFLAGS <debug-symbols>on : -g ;
flags openxl LINKFLAGS <debug-symbols>off : ;

if [ os.name ] = AIX
{
flags openxl.compile C++FLAGS : -ffunction-sections ;

# The -bnoipath strips the prepending (relative) path of libraries from
# the loader section in the target library or executable. Hence, during
# load-time LIBPATH (identical to LD_LIBRARY_PATH) or a hard-coded
# -blibpath (*similar* to -lrpath/-lrpath-link) is searched. Without
# this option, the prepending (relative) path + library name is
# hard-coded in the loader section, causing *only* this path to be
# searched during load-time. Note that the AIX linker does not have an
# -soname equivalent, this is as close as it gets.
#
# The above options are definitely for AIX 5.x, and most likely also for
# AIX 4.x and AIX 6.x. For details about the AIX linker see:
# http://download.boulder.ibm.com/ibmdl/pub/software/dw/aix/es-aix_ll.pdf
#
flags openxl.link LINKFLAGS <link>shared : -bnoipath ;

# Run-time linking
flags openxl.link EXE-LINKFLAGS <link>shared : -brtl ;
}

# Profiling
flags openxl CFLAGS <profiling>on : -pg ;
flags openxl LINKFLAGS <profiling>on : -pg ;

flags openxl.compile OPTIONS <cflags> ;
flags openxl.compile.c++ OPTIONS <cxxflags> ;
flags openxl DEFINES <define> ;
flags openxl UNDEFS <undef> ;
flags openxl HDRS <include> ;
flags openxl STDHDRS <sysinclude> ;
flags openxl.link OPTIONS <linkflags> ;
flags openxl ARFLAGS <arflags> ;

flags openxl LIBPATH <library-path> ;
flags openxl NEEDLIBS <library-file> ;
flags openxl FINDLIBS <find-shared-library> ;
flags openxl FINDLIBS <find-static-library> ;

# Select the compiler name according to the threading model.
flags openxl OPENXL_C_COMPILER <threading>single : ibm-clang_r ;
flags openxl OPENXL_C_COMPILER <threading>multi : ibm-clang_r ;
flags openxl OPENXL_CXX_COMPILER <threading>single : ibm-clang++_r ;
flags openxl OPENXL_CXX_COMPILER <threading>multi : ibm-clang++_r ;

SPACE = " " ;

actions openxl.link bind NEEDLIBS
{
$(OPENXL_CXX_COMPILER) $(EXE-LINKFLAGS) $(LINKFLAGS) -o "$(<[1])" -L$(LIBPATH) -L$(STDLIBPATH) "$(>)" "$(NEEDLIBS)" "$(NEEDLIBS)" -l$(FINDLIBS) $(OPTIONS) $(USER_OPTIONS)
}

actions openxl.link.dll bind NEEDLIBS
{
$(OPENXL_CXX_COMPILER) -shared -Wl,-G $(LINKFLAGS) -o "$(<[1])" $(HAVE_SONAME)-Wl,-soname$(SPACE)-Wl,$(<[-1]:D=) -L$(LIBPATH) -L$(STDLIBPATH) "$(>)" "$(NEEDLIBS)" "$(NEEDLIBS)" -l$(FINDLIBS) $(OPTIONS) $(USER_OPTIONS)
}

actions openxl.compile.c
{
$(OPENXL_C_COMPILER) -c $(OPTIONS) $(USER_OPTIONS) -I$(BOOST_ROOT) -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -o "$(<)" "$(>)"
}

actions openxl.compile.c++
{
$(OPENXL_CXX_COMPILER) -c $(OPTIONS) $(USER_OPTIONS) -I$(BOOST_ROOT) -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -o "$(<)" "$(>)"
}

actions updated together piecemeal openxl.archive
{
ar $(ARFLAGS) ru "$(<)" "$(>)"
}
161 changes: 161 additions & 0 deletions src/tools/xlclang.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Copyright Vladimir Prus 2004.
# Copyright Toon Knapen 2004.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt
# or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)

#| tag::doc[]

[[bbv2.reference.tools.compiler.xlclang]]
= IBM Visual Age

The `xlclang` module supports the http://www.ibm.com/software/ad/xlclang[IBM
Visual Age] C++ Compiler, for the AIX operating system. Versions 7.1 and
8.0 are known to work.

The module is initialized using the following syntax:

----
using xlclang ;
----

The module does not accept any initialization options. The compiler
should be installed in the `/usr/xlclang/bin` directory.

Later versions of Visual Age are known as XL C/C++. They were not tested
with the the `xlclang` module.

|# # end::doc[]

#
# B2 V2 toolset for the IBM XL C++ compiler
#

import toolset : flags ;
import feature ;
import common ;
import generators ;
import os ;

feature.extend toolset : xlclang ;
toolset.inherit xlclang : unix ;
generators.override xlclang.prebuilt : builtin.prebuilt ;
generators.override xlclang.searched-lib-generator : searched-lib-generator ;

# Configure the xlclang toolset
rule init ( version ? : command * : options * )
{
local condition = [
common.check-init-parameters xlclang : version $(version) ] ;

command = [ common.get-invocation-command xlclang : xlclang++
: $(command) : "/opt/IBM/xlC/16.1.0/bin/xlclang++" ] ;

common.handle-options xlclang : $(condition) : $(command) : $(options) ;
}

# Declare generators
generators.register-c-compiler xlclang.compile.c : C : OBJ : <toolset>xlclang ;
generators.register-c-compiler xlclang.compile.c++ : CPP : OBJ : <toolset>xlclang ;

# Declare flags
flags xlclang CFLAGS <optimization>speed : -O3 -qstrict ;
flags xlclang CFLAGS <optimization>space : -O2 -qcompact ;

# Discretionary inlining (not recommended)
flags xlclang CFLAGS <inlining>off : -qnoinline ;
flags xlclang CFLAGS <inlining>on : -qinline ;
#flags xlclang CFLAGS <inlining>full : -qinline ;
flags xlclang CFLAGS <inlining>full : ;

# Exception handling
flags xlclang C++FLAGS <exception-handling>off : -qnoeh ;
flags xlclang C++FLAGS <exception-handling>on : -qeh ;

# Run-time Type Identification
flags xlclang C++FLAGS <rtti>off : -qnortti ;
flags xlclang C++FLAGS <rtti>on : -qrtti ;

# Enable 64-bit memory addressing model
flags xlclang CFLAGS <address-model>64 : -q64 ;
flags xlclang LINKFLAGS <address-model>64 : -q64 ;
flags xlclang ARFLAGS <target-os>aix/<address-model>64 : -X 64 ;

# Use absolute path when generating debug information
flags xlclang CFLAGS <debug-symbols>on : -g -qfullpath ;
flags xlclang LINKFLAGS <debug-symbols>on : -g -qfullpath ;
flags xlclang LINKFLAGS <debug-symbols>off : -s ;

if [ os.name ] = AIX
{
flags xlclang.compile C++FLAGS : -qfuncsect ;

# The -bnoipath strips the prepending (relative) path of libraries from
# the loader section in the target library or executable. Hence, during
# load-time LIBPATH (identical to LD_LIBRARY_PATH) or a hard-coded
# -blibpath (*similar* to -lrpath/-lrpath-link) is searched. Without
# this option, the prepending (relative) path + library name is
# hard-coded in the loader section, causing *only* this path to be
# searched during load-time. Note that the AIX linker does not have an
# -soname equivalent, this is as close as it gets.
#
# The above options are definitely for AIX 5.x, and most likely also for
# AIX 4.x and AIX 6.x. For details about the AIX linker see:
# http://download.boulder.ibm.com/ibmdl/pub/software/dw/aix/es-aix_ll.pdf
#
flags xlclang.link LINKFLAGS <link>shared : -bnoipath ;

# Run-time linking
flags xlclang.link EXE-LINKFLAGS <link>shared : -brtl ;
}

# Profiling
flags xlclang CFLAGS <profiling>on : -pg ;
flags xlclang LINKFLAGS <profiling>on : -pg ;

flags xlclang.compile OPTIONS <cflags> ;
flags xlclang.compile.c++ OPTIONS <cxxflags> ;
flags xlclang DEFINES <define> ;
flags xlclang UNDEFS <undef> ;
flags xlclang HDRS <include> ;
flags xlclang STDHDRS <sysinclude> ;
flags xlclang.link OPTIONS <linkflags> ;
flags xlclang ARFLAGS <arflags> ;

flags xlclang LIBPATH <library-path> ;
flags xlclang NEEDLIBS <library-file> ;
flags xlclang FINDLIBS <find-shared-library> ;
flags xlclang FINDLIBS <find-static-library> ;

# Select the compiler name according to the threading model.
flags xlclang XLCLANG_C_COMPILER <threading>single : xlclang ;
flags xlclang XLCLANG_C_COMPILER <threading>multi : xlclang ;
flags xlclang XLCLANG_CXX_COMPILER <threading>single : xlclang++ ;
flags xlclang XLCLANG_CXX_COMPILER <threading>multi : xlclang++ ;

SPACE = " " ;

actions xlclang.link bind NEEDLIBS
{
$(XLCLANG_CXX_COMPILER) $(EXE-LINKFLAGS) $(LINKFLAGS) -o "$(<[1])" -L$(LIBPATH) -L$(STDLIBPATH) "$(>)" "$(NEEDLIBS)" "$(NEEDLIBS)" -l$(FINDLIBS) $(OPTIONS) $(USER_OPTIONS)
}

actions xlclang.link.dll bind NEEDLIBS
{
$(XLCLANG_CXX_COMPILER) -G $(LINKFLAGS) -o "$(<[1])" $(HAVE_SONAME)-Wl,-soname$(SPACE)-Wl,$(<[-1]:D=) -L$(LIBPATH) -L$(STDLIBPATH) "$(>)" "$(NEEDLIBS)" "$(NEEDLIBS)" -l$(FINDLIBS) $(OPTIONS) $(USER_OPTIONS)
}

actions xlclang.compile.c
{
$(XLCLANG_C_COMPILER) -c $(OPTIONS) $(USER_OPTIONS) -I$(BOOST_ROOT) -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -o "$(<)" "$(>)"
}

actions xlclang.compile.c++
{
$(XLCLANG_CXX_COMPILER) -c $(OPTIONS) $(USER_OPTIONS) -I$(BOOST_ROOT) -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -o "$(<)" "$(>)"
}

actions updated together piecemeal xlclang.archive
{
ar $(ARFLAGS) ru "$(<)" "$(>)"
}

0 comments on commit 276452f

Please sign in to comment.