Skip to content

Commit fde79a5

Browse files
committed
[ATfL] Add package documentation
This patch adds the ATfL package documentation which should land into: 1. Our on-line page(s) 2. Our release .deb packages 3. Our release .rpm packages The markdown documents introduced by this patch have landed into the arm-software/linux/docs directory. This follows the same guidance that has been already agreed for the ATfE product (see [1]). Additionally, an index.md file has been created which follows the convention already observed in the LLVM's documentation directories (e.g., [2]). The files from the arm-software/linux/docs directory are being copied into the arm/docs directory of the tarball and this is happening in the build.sh script also modified by this patch. Whatever lands into that directory, should act as a basis for further rendering of the on-line page(s) and the PDF document(s) in our CI pipelines. [1] https://github.com/arm/arm-toolchain/blob/arm-software/arm-software/docs/README.md [2] https://github.com/arm/arm-toolchain/blob/arm-software/flang/docs/index.md
1 parent b9c5105 commit fde79a5

File tree

8 files changed

+685
-1
lines changed

8 files changed

+685
-1
lines changed

arm-software/docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Toolchain for Embedded and Arm Toolchain for Linux.
66
Documentation that is specific to a toolchain should be placed in the
77
toolchain specific subdirectory. For example documentation for Arm
88
Toolchain for Embedded should go into the `arm-software/embedded/docs`
9-
directory.
9+
directory while documentation for Arm Toolchain for Linux should go
10+
into the `arm-software/linux/docs` directory.

arm-software/linux/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ MKMODULEDIRS_PATH=${MKMODULEDIRS_PATH:-"${BASE_DIR}/mkmoduledirs.sh.var"}
1616
SOURCES_DIR=${SOURCES_DIR:-"$(git -C "${BASE_DIR}" rev-parse --show-toplevel)"}
1717
LIBRARIES_DIR=${LIBRARIES_DIR:-"${BASE_DIR}/lib"}
1818
PATCHES_DIR=${PATCHES_DIR:-"${BASE_DIR}/patches"}
19+
DOCS_DIR=${DOCS_DIR:-"${BASE_DIR}/docs"}
1920
BUILD_DIR=${BUILD_DIR:-"${BASE_DIR}/build"}
2021
ATFL_DIR=${ATFL_DIR:-"${BUILD_DIR}/atfl"}
2122
LOGS_DIR=${LOGS_DIR:-"${BASE_DIR}/logs"}
@@ -186,6 +187,8 @@ Environment Variables:
186187
(default: $LIBRARIES_DIR)
187188
PATCHES_DIR The optional directory where all patches will be stored
188189
(default: $PATCHES_DIR)
190+
DOCS_DIR The directory where ATfL documents will be stored
191+
(default: $DOCS_DIR)
189192
BUILD_DIR The directory where all build output will be stored
190193
(default: $BUILD_DIR)
191194
LOGS_DIR The directory where all build logs will be stored
@@ -384,6 +387,8 @@ package() {
384387
cp "${SBOM_FILE_PATH}" "${ATFL_DIR}/ATfL-SBOM.spdx.json"
385388
mkdir -p "${ATFL_DIR}/arm"
386389
cp "${MKMODULEDIRS_PATH}" "${ATFL_DIR}/arm/mkmoduledirs.sh"
390+
mkdir -p "${ATFL_DIR}/arm/docs"
391+
cp "${DOCS_DIR}"/*.md "${ATFL_DIR}/arm/docs"
387392
sed -i "s/%ATFL_VERSION%/${ATFL_VERSION}/g" "${ATFL_DIR}/arm/mkmoduledirs.sh"
388393
sed -i "s/%ATFL_BUILD%/${BUILD_NUMBER:-"unknown"}/g" "${ATFL_DIR}/arm/mkmoduledirs.sh"
389394
sed -i "s/%ATFL_INSTALL_PREFIX%/\$\(dirname \$\(dirname \`realpath \$BASH_SOURCE\`\)\)/g" "${ATFL_DIR}/arm/mkmoduledirs.sh"
@@ -500,6 +505,12 @@ then
500505
exit 1
501506
fi
502507

508+
if ! [[ -e "${DOCS_DIR}" ]]
509+
then
510+
echo "The documentation directory is configured incorrectly or does not exist."
511+
exit 1
512+
fi
513+
503514
if ! [[ -e "${SOURCES_DIR}" ]]
504515
then
505516
echo "The sources directory is configured incorrectly or does not exist."

arm-software/linux/build.sh-HOWTO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ The `build.sh` script reads the following environment variables:
147147
(default: `arm-software/linux/lib`)
148148
- `PATCHES_DIR` - The **optional** directory where all patches will be stored
149149
(default: `arm-software/linux/patches`)
150+
- `DOCS_DIR` - The directory where ATfL documents will be stored
151+
(default: `arm-software/linux/docs`)
150152
- `BUILD_DIR` - The directory where all build will be happening
151153
(default: `arm-software/linux/build`)
152154
- `LOGS_DIR` - The directory where all build logs will be stored
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
## Getting Started
2+
3+
This document describes how to get started with the already installed Arm
4+
Toolchain for Linux. Here you will find out how to use it to compile a source
5+
code into an executable binary.
6+
7+
### Looking at the toolchain
8+
9+
The default installation site of Arm Toolchain For Linux is the
10+
`/opt/arm/arm-toolchain-for-linux` directory. It contains a complete set of LLVM
11+
tooling, header files, compiler libraries and runtime libraries (including the
12+
OpenMP runtime). The main tools are as follows:
13+
14+
* `armclang` - the C compiler
15+
* `armclang++` - the C++ compiler
16+
* `armflang` - the Fortran compiler
17+
18+
Note that the LLVM equivalents of these commands (`clang`, `clang++`, `flang`)
19+
are also available and functionally identical.
20+
21+
### Configure and load environment modules
22+
23+
After installation, you should be able to invoke any of those commands with
24+
their absolute paths, e.g.:
25+
26+
```
27+
$ /opt/arm/arm-toolchain-for-linux/bin/armclang -print-resource-dir
28+
/opt/arm/arm-toolchain-for-linux/lib/clang/<version>
29+
```
30+
31+
Although fully operable, this is not the most convenient way of using the
32+
toolchain. Therefore, we recommend using the environment modules. These can be
33+
installed on most of the existing Linux distributions, as presented below.
34+
35+
#### Ubuntu systems
36+
37+
```
38+
$ sudo apt install environment-modules
39+
```
40+
41+
#### Red Hat Enterprise Linux and Amazon Linux systems
42+
43+
```
44+
$ sudo dnf install environment-modules
45+
```
46+
47+
#### SUSE Linux Enterprise Server systems
48+
49+
```
50+
$ sudo zypper install environment-modules
51+
```
52+
53+
After installing environment modules, you need to execute a profile script which
54+
matches with your default shell:
55+
56+
#### BASH
57+
58+
```
59+
$ source /etc/profile.d/modules.sh
60+
```
61+
62+
#### csh or tcsh
63+
64+
```
65+
$ source /etc/profile.d/modules.csh
66+
```
67+
68+
Use the `module use` command to update your `MODULEPATH` environment variable to
69+
include the path to the Arm Toolchain For Linux module files directory:
70+
71+
```
72+
$ module use /opt/arm/modulefiles
73+
```
74+
75+
Alternatively, you can set or amend your `MODULEPATH` environment variable
76+
manually. Use the `module avail` command to examine the list of available modules.
77+
78+
To load the module for Arm Toolchain for Linux, type:
79+
80+
```
81+
$ module load atfl
82+
```
83+
84+
This should load the default version of Arm Toolchain for Linux. Alternatively,
85+
if multiple versions are available, you can load the desired version by
86+
specifying `atfl/<version>`.
87+
88+
From now on, the toolchain commands should be accessible from the command line:
89+
90+
```
91+
$ which armclang
92+
/opt/arm/arm-toolchain-for-linux/bin/armclang
93+
94+
$ which armclang++
95+
/opt/arm/arm-toolchain-for-linux/bin/armclang++
96+
97+
$ which armflang
98+
/opt/arm/arm-toolchain-for-linux/bin/armflang
99+
```
100+
101+
### Using the compiler
102+
103+
#### Example 1: Compile and run an example C program
104+
105+
Consider a simple program stored in a `.c` file, for example: `hello.c`:
106+
107+
```
108+
#include <stdio.h>
109+
110+
int main()
111+
{
112+
printf("Hello, World!");
113+
return 0;
114+
}
115+
```
116+
117+
To generate an executable binary, compile your example C program with the
118+
`armclang` compiler. Specify the input file, `hello.c`, and the binary name
119+
(using `-o`), `hello`:
120+
121+
```
122+
$ armclang -o hello hello.c
123+
```
124+
125+
Run the generated binary `hello`:
126+
127+
```
128+
$ ./hello
129+
Hello, World!
130+
```
131+
132+
#### Example 2: Compile and run an example Fortran program
133+
134+
Consider a simple program stored in a `.f90` file, for example: `hello.f90`:
135+
136+
```
137+
program hello
138+
print *, 'hello world'
139+
end program
140+
```
141+
142+
To generate an executable binary, compile your example Fortran program with the
143+
`armflang` compiler. Specify the input file, `hello.f90`, and the binary name
144+
(using `-o`), `hello`:
145+
146+
```
147+
$ armflang -o hello hello.f90
148+
```
149+
150+
Run the generated binary `hello`:
151+
152+
```
153+
$ ./hello
154+
hello world
155+
```
156+
157+
### Compile and link C/C++ programs
158+
159+
To generate an executable binary, compile your source file (for example,
160+
`source.c`) with the `armclang` command:
161+
162+
```
163+
$ armclang source.c
164+
```
165+
166+
A binary with the filename `a.out` is the output.
167+
168+
Optionally, use the `-o` option to set the binary filename (for example, `binary`):
169+
170+
```
171+
$ armclang -o binary source.c
172+
```
173+
174+
You can specify multiple source files on a single line. Each source file is
175+
compiled individually and then linked into a single executable binary. For
176+
example, to compile the source files `source1.c` and `source2.c`, use:
177+
178+
```
179+
$ armclang -o binary source1.c source2.c
180+
```
181+
182+
To compile each of your source files individually into an object (`.o`) file,
183+
specify the compile-only option, `-c`, and then pass the resulting object files
184+
into another invocation of `armclang` to link them into an executable binary:
185+
186+
```
187+
$ armclang -c source1.c
188+
189+
$ armclang -c source2.c
190+
191+
$ armclang -o binary source1.o source2.o
192+
```
193+
194+
#### Note
195+
196+
For the C/C++ compiler's command line arguments reference visit this page:
197+
[Clang command line argument reference](https://releases.llvm.org/20.1.0/tools/clang/docs/ClangCommandLineReference.html).
198+
199+
### Compile and link Fortran programs
200+
201+
To generate an executable binary, compile your source file (for example,
202+
`source.f90`) with the `armflang` command:
203+
204+
```
205+
$ armflang source.f90
206+
```
207+
208+
A binary with the filename `a.out` is the output.
209+
210+
You can specify multiple source files on a single line. Each source file is
211+
compiled individually and then linked into a single executable binary. For
212+
example, to compile the source files `source1.f90` and `source2.f90`, use:
213+
214+
```
215+
$ armflang -o binary source1.f90 source2.f90
216+
```
217+
218+
To compile each of your source files individually into an object (`.o`) file,
219+
specify the compile-only option, `-c`, and then pass the resulting object files
220+
into another invocation of `armflang` to link them into an executable binary:
221+
222+
```
223+
$ armflang -c source1.f90
224+
225+
$ armflang -c source2.f90
226+
227+
$ armflang -o binary source1.o source2.o
228+
```
229+
230+
When mixing both C/C++ and Fortran codes in a single application, it is
231+
important to to make sure that the Fortran runtime library is always linked in.
232+
This can be ensured by using the `armflang` command for linking:
233+
234+
```
235+
$ armflang -c source1.f90
236+
237+
$ armclang -c source2.c
238+
239+
$ armflang -o binary source1.o source2.o
240+
```
241+
242+
#### Note
243+
244+
For the Fortran compiler's command line arguments reference visit this page:
245+
[Flang command line argument reference](https://flang.llvm.org/docs/FlangCommandLineReference.html).
246+
247+
### Increase the optimization level
248+
249+
To control the optimization level, specify the `-O<level>` option on your
250+
compile line, and replace `<level>` with one of `0`, `1`, `2` or `3`. The `-O0`
251+
option is the lowest, and the default, optimization level. `-O3` is the highest
252+
optimization level. Arm compilers performs auto-vectorization at level `-O2` and
253+
above.
254+
255+
For example, to compile the `source.c` file into a binary called `binary`, and
256+
use the `-O3` optimization level, use:
257+
258+
```
259+
$ armclang -O3 -o binary source.c
260+
```
261+
262+
To compile the `source.f90` file into a binary called binary, and use the `-O3`
263+
optimization level, use:
264+
265+
```
266+
$ armflang -O3 -o binary source.f90
267+
```
268+
269+
#### Note
270+
271+
Similarly to other compilers, the Arm Toolchain for Linux C and C++ compilers
272+
can also be supplied with the `-Ofast` option. This will however result in
273+
displaying the following deprecation warning:
274+
275+
```
276+
warning: argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior, or '-O3' to enable only conforming optimizations [-Wdeprecated-ofast]
277+
```
278+
279+
As the warning message states, the effect of applying the `-Ofast` option when
280+
compiling the C/C++ programs can be achieved by using the `-O3 -ffast-math`
281+
options instead.
282+
283+
In case of Fortran, the use of the `-Ofast` option triggers the following
284+
deprecation warning:
285+
286+
```
287+
warning: argument '-Ofast' is deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior, or '-O3 -fstack-arrays' to enable only conforming optimizations [-Wdeprecated-ofast]
288+
```
289+
290+
As the warning message states, the effect of applying the `-Ofast` option when
291+
compiling Fortram programs can be achieved by using the
292+
`-O3 -ffast-math -fstack-arrays` options instead.
293+
294+
### Compile and optimize using CPU auto-detection
295+
296+
If you tell the compiler what target CPU your application will run on, it can
297+
make target-specific optimization decisions. Target-specific optimization
298+
decisions help ensure your application runs as efficiently as possible. To tell
299+
the compiler to make target-specific compilation decisions, use the
300+
`-mcpu=<target>` option and replace `<target>` with your target processor (from
301+
a supported list of targets).
302+
303+
In addition, the `-mcpu` option also supports the `native` argument.
304+
`-mcpu=native` enables the compiler to auto-detect the architecture and
305+
processor type of the CPU that you are running the compiler on.
306+
307+
For example, to auto-detect the target CPU and optimize your C application for
308+
this target, use:
309+
310+
```
311+
$ armclang -O3 -mcpu=native -o binary source.c
312+
```
313+
314+
To auto-detect the target CPU and optimize your Fortran application for this
315+
target, use:
316+
317+
```
318+
$ armflang -O3 -mcpu=native -o binary source.f90
319+
```
320+
321+
The `-mcpu` option supports a range of Armv8-A-based Systems-on-Chips (SoCs).
322+
When `-mcpu` is not specified, by default, `-mcpu=generic` is set, which
323+
generates portable output suitable for any Armv8-A-based target.
324+
325+
#### Note
326+
327+
* The optimizations that are performed from setting the `-mcpu` option (also
328+
known as hardware, or CPU, tuning) are independent of the optimizations that
329+
are performed from setting the `-O<level>` option.
330+
331+
* If you run the compiler on one target, but will run the application you are
332+
compiling on a different target, do not use `-mcpu=native`. Instead, use
333+
`-mcpu=<target>` where `<target>` is the target processor that you will run
334+
the application on.

0 commit comments

Comments
 (0)