Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error in inline assembly when targeting armv7 #294

Closed
j-jorge opened this issue Dec 25, 2024 · 4 comments · Fixed by #295
Closed

Syntax error in inline assembly when targeting armv7 #294

j-jorge opened this issue Dec 25, 2024 · 4 comments · Fixed by #295

Comments

@j-jorge
Copy link

j-jorge commented Dec 25, 2024

Hello, I encounter an issue when compiling the armeabi-v7a library of my Android project. The problem can be reproduced by compiling a file with this content:

// test.cpp
#include <boost/unordered/unordered_flat_map.hpp>

The compilation fails with the following message:

<inline asm>:1:41: error: expected '%<type>' or "<type>"
    1 | .pushsection ".debug_gdb_scripts", "MS",@progbits,1
      |                                         ^
<inline asm>:318:12: error: .popsection without corresponding .pushsection
  318 | .popsection
      |            ^
2 errors generated.

The command used to compile the file is:

path/to/ndk/27.2.12479018/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ \
  --target=armv7-none-linux-androideabi21 \
  --sysroot=path/to/ndk/27.2.12479018/toolchains/llvm/prebuilt/linux-x86_64/sysroot \
  -Ipath/to/include/ \
  -fvisibility=hidden \
  -fdata-sections \
  -ffunction-sections \
  -funwind-tables \
  -fstack-protector-strong \
  -no-canonical-prefixes \
  -D_FORTIFY_SOURCE=2 \
  -march=armv7-a \
  -mthumb \
  -fexceptions \
  -frtti \
  -stdlib=libc++ \
  -g \
  -fno-limit-debug-info \
  -std=c++20 \
  -fPIC \
  -fcolor-diagnostics -pthread \
  -MD \
  -MT \
  test.o \
  -c test.cpp

Boost 1.87.0 is installed in the path/to/include directory passed to the -I option. There is no problem with the arm64 nor the x86_64 architectures.

As a workaround I can compile with -DBOOST_ALL_NO_EMBEDDED_GDB_SCRIPTS but I which I did not have to do that (i.e. that the inline assembly would be omitted when the target does not support it).

Note that it happens here with Boost.Unordered but I expect a similar problem with Boost.Interprocess and Boost.Json as they also use this GDB macro :)

@j-jorge j-jorge changed the title Syntax error in inline assembly when targetting armv7 Syntax error in inline assembly when targeting armv7 Dec 25, 2024
@grisumbras
Copy link
Member

Related llvm/llvm-project#120871

@grisumbras
Copy link
Member

Looking at the workaround linked in that issue, another option is to use -fno-integrated-as to use system assembler rather than the integrated Clang assembler.

@grisumbras
Copy link
Member

Apparently, this fixes it: ned14/outcome#308.

@pdimov pdimov transferred this issue from boostorg/boost Dec 26, 2024
@grisumbras
Copy link
Member

Note on targets where the @ character is the start of a comment (eg ARM) then another character is used instead. For example the ARM port uses the % character.

(https://www.sourceware.org/binutils/docs/as/Section.html)

So, this is actually the expected behaviour. Interestingly, I don't see universal support for % as section type prefix documented, but it appears to be the case. I tested a few targets on CE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants