1# Multi-language Runtime Subsystem Changelog
2## cl.arkcompiler.1 New Alarms and Existing Alarm Enhancements for LLVM
3
4**Change Impact**
5
6By default, the **-Werror** option is disabled for the OpenHarmony NDK. If you have enabled the **-Werror** option, you are advised to correct the code based on the suggestions in the check result or mask the errors.
7
8 **Changes in Key Compilation Check Rules**
9
10| New Check Item| Description| Suggestion|
11| --- | --- | --- |
12| Wunused-but-set-variable | An alarm is generated when the code contains unused variables (including the ++ operator).| Add the **maybe_unused** attribute when defining variables or use macros to distinguish variables.|
13| Wdeprecated-non-prototype | An alarm is generated when a function without a prototype exists in the code.| Add a function prototype and specify the parameters.|
14| Wunqualified-std-cast-call | An alarm is generated when **std::move** is incorrectly used in code.| Specify the use case of **std::move** and check the code.|
15| Wdeprecated-builtins | An alarm is generated when a deprecated built-in function is used in the code.| Use the substitute function.|
16| Warray-parameter | An alarm is generated when a function parameter contains an array that uses inconsistent forms.| Ensure the consistency of the function parameter.|
17| Wbitwise-instead-of-logical | An alarm is generated when bitwise OR is used in Boolean operations.| Use logical OR in Boolean operations.|
18| Wint-conversion | An alarm is generated when an int variable is converted to a pointer in the code.| Use a new implementation mode in the code.|
19| Wdeprecated-declarations | An alarm is generated when a deprecated definition (including functions and variables) is used in code.| Use a new implementation mode in the code.|
20| Wnull-pointer-subtraction | An alarm is generated when a null pointer is used in the subtraction operation.| Do not a null pointer in the subtraction operation.|
21| Wunused-but-set-parameter | An alarm is generated when a function contains unused parameters.| Delete unused parameters.|
22| Warray-bounds | An alarm is generated when out-of-bounds access to an array occurs in the code.| Modify the out-of-bounds access.|
23| Wdeprecated-pragma | An alarm is generated when a deprecated macro is used in the code.| Delete the deprecated macro.|
24| Wreserved-identifier | An alarm is generated when a variable starting with __ is used in the code.| Check the code to prevent variables starting with underscores (_) from being used externally.|
25
26 **Adaptation Guide**
27
281. For issues in the code that are not detected by LLVM 12, check and update the code.
292. Some old implementations are discarded during LLVM update. Adapt to the new rules and update the code.
303. If you believe a certain type of error can be masked, use the **-Wno-xxx** option to mask the error.
31
32Defective code example
33
34```
35void Heap::Resume(TriggerGCType gcType)
36{
37    if (mode_ != HeapMode::SPAWN &&
38        activeSemiSpace_->AdjustCapacity(inactiveSemiSpace_->GetAllocatedSizeSinceGC())) {
39        // If activeSpace capacity changes, oldSpace maximumCapacity should change too.
40        size_t multiple = 2;
41        // oldSpaceMaxLimit is assigned a value but is not used.
42        size_t oldSpaceMaxLimit = 0;
43        if (activeSemiSpace_->GetInitialCapacity() >= inactiveSemiSpace_->GetInitialCapacity()) {
44            size_t delta = activeSemiSpace_->GetInitialCapacity() - inactiveSemiSpace_->GetInitialCapacity();
45            oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() - delta * multiple;
46        } else {
47            size_t delta = inactiveSemiSpace_->GetInitialCapacity() - activeSemiSpace_->GetInitialCapacity();
48            oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() + delta * multiple;
49        }
50        inactiveSemiSpace_->SetInitialCapacity(activeSemiSpace_->GetInitialCapacity());
51    }
52    // irrelated code ...
53}
54```
55
56The oldSpaceMaxLimit variable is not used, and the compiler reports an alarm.
57
58```
59../../arkcompiler/ets_runtime/ecmascript/mem/heap.cpp:247:16: error: variable 'oldSpaceMaxLimit' set but not used [-Werror,-Wunused-but-set-variable]
60        size_t oldSpaceMaxLimit = 0;
61```
62
63The error is rectified after the attribute is added.
64
65```
66void Heap::Resume(TriggerGCType gcType)
67{
68    if (mode_ != HeapMode::SPAWN &&
69        activeSemiSpace_->AdjustCapacity(inactiveSemiSpace_->GetAllocatedSizeSinceGC())) {
70        // If activeSpace capacity changes, oldSpace maximumCapacity should change too.
71        size_t multiple = 2;
72        // Add the maybe_unused attribute and declare that the variable oldSpaceMaxLimit may not be used.
73        [[maybe_unused]] size_t oldSpaceMaxLimit = 0;
74        if (activeSemiSpace_->GetInitialCapacity() >= inactiveSemiSpace_->GetInitialCapacity()) {
75            size_t delta = activeSemiSpace_->GetInitialCapacity() - inactiveSemiSpace_->GetInitialCapacity();
76            oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() - delta * multiple;
77        } else {
78            size_t delta = inactiveSemiSpace_->GetInitialCapacity() - activeSemiSpace_->GetInitialCapacity();
79            oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() + delta * multiple;
80        }
81        inactiveSemiSpace_->SetInitialCapacity(activeSemiSpace_->GetInitialCapacity());
82    }
83    // irrelated code ...
84}
85```
86
87## cl.arkcompiler.2 LLVM Parsing Format Changed
88
89**Change Impact**
90
91When your code depends on the **version-script** or **-gcc-toolchain** option, parsing may fail if you continue to use the original LLVM 12 configuration file or options.
92
93**Changes in Key Compilation Rules**
94
951. The symbol representation is changed. In the new version, consecutive greater signs (>) are represented as ">>", which was represented as "> >" in the old version.
962. The -xx options are deprecated. For example, the **-gcc-toolchain** option is replaced by the **--gcc-toolchain** option. (This option has been marked as deprecated in versions later than Clang 3.4 and is officially deprecated in LLVM15.)
97
98**Adaptation Guide**
99
100If two consecutive greater signs (>) exist in the code (without considering the number of spaces in the middle), they will be parsed as "> >" in the older version and ">>" in the new version in version-script (due to mangling differences). In LLVM15, ">>" must be used.
101
102Original configuration file
103
104```
105{
106  global:
107  extern "C++" {
108    "google::protobuf::TextFormat::ParseFromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Message*)";
109    // In LLVM 12, "> >" can be parsed, but ">>" cannot.
110    "google::protobuf::TextFormat::PrintToString(google::protobuf::Message const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)";
111  };
112  local:
113    *;
114}
115```
116
117Modified configuration file
118
119```
120{
121  global:
122  extern "C++" {
123    "google::protobuf::TextFormat::ParseFromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, google::protobuf::Message*)";
124    // In LLVM 15, ">>" can be parsed.
125    "google::protobuf::TextFormat::PrintToString(google::protobuf::Message const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)";
126  };
127  local:
128    *;
129}
130```
131
132## cl.arkcompiler.3 LLVM emu-tls Changed
133
134**Change Impact**
135
136If you use both LLVM 12 and LLVM 15 (this behavior is prohibited) for your code, the emu-tls symbol cannot be found in libc++.so.
137
138**Key Library Dependency Changes**
139
140In LLVM 15, the emu-tls symbol is extracted from the target binary file to libc++.so. That is, the __emutls_get_address attribute changes from an internal symbol to an externally visible symbol, which is included in libc++.so. As a result, the compiled dynamic library may depend on libc++.so.
141
142**Adaptation Guide**
143
144This symbol is also in libclang_rt.builtin.a. If you do not want the compiled dynamic library to depend on libc++.so, statically link the libclang_rt.builtin.a library.
145
146## cl.arkcompiler.4 LLVM Official Release Notes
147
148**Change Impact**
149
150New features are added and internal interfaces are changed (such as IR in LLVM and compiler front-end modification). For details, see the official release notes.
151
152**Key Documents**
153
154https://releases.llvm.org/13.0.0/docs/ReleaseNotes.html
155https://releases.llvm.org/14.0.0/docs/ReleaseNotes.html
156https://releases.llvm.org/15.0.0/docs/ReleaseNotes.html
157
158**Adaptation Guide**
159
160For details about the updates and adaptation guide, see the official documents.
161