1e41f4b71Sopenharmony_ci# Multi-language Runtime Subsystem Changelog 2e41f4b71Sopenharmony_ci## cl.arkcompiler.1 New Alarms and Existing Alarm Enhancements for LLVM 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci**Change Impact** 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciBy 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. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci **Changes in Key Compilation Check Rules** 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci| New Check Item| Description| Suggestion| 11e41f4b71Sopenharmony_ci| --- | --- | --- | 12e41f4b71Sopenharmony_ci| 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.| 13e41f4b71Sopenharmony_ci| 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.| 14e41f4b71Sopenharmony_ci| 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.| 15e41f4b71Sopenharmony_ci| Wdeprecated-builtins | An alarm is generated when a deprecated built-in function is used in the code.| Use the substitute function.| 16e41f4b71Sopenharmony_ci| Warray-parameter | An alarm is generated when a function parameter contains an array that uses inconsistent forms.| Ensure the consistency of the function parameter.| 17e41f4b71Sopenharmony_ci| Wbitwise-instead-of-logical | An alarm is generated when bitwise OR is used in Boolean operations.| Use logical OR in Boolean operations.| 18e41f4b71Sopenharmony_ci| 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.| 19e41f4b71Sopenharmony_ci| 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.| 20e41f4b71Sopenharmony_ci| 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.| 21e41f4b71Sopenharmony_ci| Wunused-but-set-parameter | An alarm is generated when a function contains unused parameters.| Delete unused parameters.| 22e41f4b71Sopenharmony_ci| Warray-bounds | An alarm is generated when out-of-bounds access to an array occurs in the code.| Modify the out-of-bounds access.| 23e41f4b71Sopenharmony_ci| Wdeprecated-pragma | An alarm is generated when a deprecated macro is used in the code.| Delete the deprecated macro.| 24e41f4b71Sopenharmony_ci| 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.| 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci **Adaptation Guide** 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci1. For issues in the code that are not detected by LLVM 12, check and update the code. 29e41f4b71Sopenharmony_ci2. Some old implementations are discarded during LLVM update. Adapt to the new rules and update the code. 30e41f4b71Sopenharmony_ci3. If you believe a certain type of error can be masked, use the **-Wno-xxx** option to mask the error. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ciDefective code example 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci``` 35e41f4b71Sopenharmony_civoid Heap::Resume(TriggerGCType gcType) 36e41f4b71Sopenharmony_ci{ 37e41f4b71Sopenharmony_ci if (mode_ != HeapMode::SPAWN && 38e41f4b71Sopenharmony_ci activeSemiSpace_->AdjustCapacity(inactiveSemiSpace_->GetAllocatedSizeSinceGC())) { 39e41f4b71Sopenharmony_ci // If activeSpace capacity changes, oldSpace maximumCapacity should change too. 40e41f4b71Sopenharmony_ci size_t multiple = 2; 41e41f4b71Sopenharmony_ci // oldSpaceMaxLimit is assigned a value but is not used. 42e41f4b71Sopenharmony_ci size_t oldSpaceMaxLimit = 0; 43e41f4b71Sopenharmony_ci if (activeSemiSpace_->GetInitialCapacity() >= inactiveSemiSpace_->GetInitialCapacity()) { 44e41f4b71Sopenharmony_ci size_t delta = activeSemiSpace_->GetInitialCapacity() - inactiveSemiSpace_->GetInitialCapacity(); 45e41f4b71Sopenharmony_ci oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() - delta * multiple; 46e41f4b71Sopenharmony_ci } else { 47e41f4b71Sopenharmony_ci size_t delta = inactiveSemiSpace_->GetInitialCapacity() - activeSemiSpace_->GetInitialCapacity(); 48e41f4b71Sopenharmony_ci oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() + delta * multiple; 49e41f4b71Sopenharmony_ci } 50e41f4b71Sopenharmony_ci inactiveSemiSpace_->SetInitialCapacity(activeSemiSpace_->GetInitialCapacity()); 51e41f4b71Sopenharmony_ci } 52e41f4b71Sopenharmony_ci // irrelated code ... 53e41f4b71Sopenharmony_ci} 54e41f4b71Sopenharmony_ci``` 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ciThe oldSpaceMaxLimit variable is not used, and the compiler reports an alarm. 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci``` 59e41f4b71Sopenharmony_ci../../arkcompiler/ets_runtime/ecmascript/mem/heap.cpp:247:16: error: variable 'oldSpaceMaxLimit' set but not used [-Werror,-Wunused-but-set-variable] 60e41f4b71Sopenharmony_ci size_t oldSpaceMaxLimit = 0; 61e41f4b71Sopenharmony_ci``` 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ciThe error is rectified after the attribute is added. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci``` 66e41f4b71Sopenharmony_civoid Heap::Resume(TriggerGCType gcType) 67e41f4b71Sopenharmony_ci{ 68e41f4b71Sopenharmony_ci if (mode_ != HeapMode::SPAWN && 69e41f4b71Sopenharmony_ci activeSemiSpace_->AdjustCapacity(inactiveSemiSpace_->GetAllocatedSizeSinceGC())) { 70e41f4b71Sopenharmony_ci // If activeSpace capacity changes, oldSpace maximumCapacity should change too. 71e41f4b71Sopenharmony_ci size_t multiple = 2; 72e41f4b71Sopenharmony_ci // Add the maybe_unused attribute and declare that the variable oldSpaceMaxLimit may not be used. 73e41f4b71Sopenharmony_ci [[maybe_unused]] size_t oldSpaceMaxLimit = 0; 74e41f4b71Sopenharmony_ci if (activeSemiSpace_->GetInitialCapacity() >= inactiveSemiSpace_->GetInitialCapacity()) { 75e41f4b71Sopenharmony_ci size_t delta = activeSemiSpace_->GetInitialCapacity() - inactiveSemiSpace_->GetInitialCapacity(); 76e41f4b71Sopenharmony_ci oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() - delta * multiple; 77e41f4b71Sopenharmony_ci } else { 78e41f4b71Sopenharmony_ci size_t delta = inactiveSemiSpace_->GetInitialCapacity() - activeSemiSpace_->GetInitialCapacity(); 79e41f4b71Sopenharmony_ci oldSpaceMaxLimit = oldSpace_->GetMaximumCapacity() + delta * multiple; 80e41f4b71Sopenharmony_ci } 81e41f4b71Sopenharmony_ci inactiveSemiSpace_->SetInitialCapacity(activeSemiSpace_->GetInitialCapacity()); 82e41f4b71Sopenharmony_ci } 83e41f4b71Sopenharmony_ci // irrelated code ... 84e41f4b71Sopenharmony_ci} 85e41f4b71Sopenharmony_ci``` 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci## cl.arkcompiler.2 LLVM Parsing Format Changed 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci**Change Impact** 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ciWhen 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. 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci**Changes in Key Compilation Rules** 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci1. The symbol representation is changed. In the new version, consecutive greater signs (>) are represented as ">>", which was represented as "> >" in the old version. 96e41f4b71Sopenharmony_ci2. 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.) 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci**Adaptation Guide** 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ciIf 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. 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ciOriginal configuration file 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci``` 105e41f4b71Sopenharmony_ci{ 106e41f4b71Sopenharmony_ci global: 107e41f4b71Sopenharmony_ci extern "C++" { 108e41f4b71Sopenharmony_ci "google::protobuf::TextFormat::ParseFromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Message*)"; 109e41f4b71Sopenharmony_ci // In LLVM 12, "> >" can be parsed, but ">>" cannot. 110e41f4b71Sopenharmony_ci "google::protobuf::TextFormat::PrintToString(google::protobuf::Message const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)"; 111e41f4b71Sopenharmony_ci }; 112e41f4b71Sopenharmony_ci local: 113e41f4b71Sopenharmony_ci *; 114e41f4b71Sopenharmony_ci} 115e41f4b71Sopenharmony_ci``` 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ciModified configuration file 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci``` 120e41f4b71Sopenharmony_ci{ 121e41f4b71Sopenharmony_ci global: 122e41f4b71Sopenharmony_ci extern "C++" { 123e41f4b71Sopenharmony_ci "google::protobuf::TextFormat::ParseFromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, google::protobuf::Message*)"; 124e41f4b71Sopenharmony_ci // In LLVM 15, ">>" can be parsed. 125e41f4b71Sopenharmony_ci "google::protobuf::TextFormat::PrintToString(google::protobuf::Message const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)"; 126e41f4b71Sopenharmony_ci }; 127e41f4b71Sopenharmony_ci local: 128e41f4b71Sopenharmony_ci *; 129e41f4b71Sopenharmony_ci} 130e41f4b71Sopenharmony_ci``` 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci## cl.arkcompiler.3 LLVM emu-tls Changed 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci**Change Impact** 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ciIf 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. 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci**Key Library Dependency Changes** 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ciIn 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. 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci**Adaptation Guide** 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ciThis 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. 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci## cl.arkcompiler.4 LLVM Official Release Notes 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci**Change Impact** 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ciNew 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. 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci**Key Documents** 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_cihttps://releases.llvm.org/13.0.0/docs/ReleaseNotes.html 155e41f4b71Sopenharmony_cihttps://releases.llvm.org/14.0.0/docs/ReleaseNotes.html 156e41f4b71Sopenharmony_cihttps://releases.llvm.org/15.0.0/docs/ReleaseNotes.html 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**Adaptation Guide** 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ciFor details about the updates and adaptation guide, see the official documents. 161