Skip to content

[lldb][AIX] Introducing _ALL_SOURCE macro into driver CMakeLists #120607

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

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

DhruvSrivastavaX
Copy link
Contributor

@DhruvSrivastavaX DhruvSrivastavaX commented Dec 19, 2024

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

  1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
  2. Extending LLDB to work on AIX #101657
    The complete changes for porting are present in this draft PR:
    Extending LLDB to work on AIX #102601

Adding changes for minimal build for lldb binary on AIX:
The struct winsize needed by lldb/tools/driver/Driver.cpp is only recognised in AIX under the AIX specific _ALL_SOURCE macro, hence its enablement is required here.

Review Request: @labath @DavidSpickett

@llvmbot
Copy link
Member

llvmbot commented Dec 19, 2024

@llvm/pr-subscribers-lldb

Author: Dhruv Srivastava (DhruvSrivastavaX)

Changes

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

  1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
  2. Extending LLDB to work on AIX #101657
    The complete changes for porting are present in this draft PR:
    Extending LLDB to work on AIX #102601

Adding changes for minimal build for lldb binary on AIX:
The struct winsize needed by lldb/tools/driver/Driver.cpp is only recognised in AIX under the AIX specific ALL_SOURCE macro, hence its enablement is required in certain places.

Review Request: @labath @DavidSpickett


Full diff: https://github.com/llvm/llvm-project/pull/120607.diff

1 Files Affected:

  • (modified) lldb/tools/driver/CMakeLists.txt (+5)
diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt
index cd304a047dea6d..89884ecd0601bc 100644
--- a/lldb/tools/driver/CMakeLists.txt
+++ b/lldb/tools/driver/CMakeLists.txt
@@ -11,6 +11,11 @@ if(APPLE)
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-Info.plist")
 endif()
 
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")                               
+  remove_definitions("-D_XOPEN_SOURCE=700")                                    
+  add_definitions("-D_ALL_SOURCE")                                             
+endif()
+
 add_lldb_tool(lldb
   Driver.cpp
   Platform.cpp

@DavidSpickett
Copy link
Collaborator

I assume the macro is _ALL_SOURCE with the leading underscore, you put ALL_SOURCE in the title and description.

I see that

# Google Test requires headers which need _ALL_SOURCE to build on AIX
also does this.

if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
says it does the same thing but it doesn't add _ALL_SOURCE it only removes the other macro.

The one in third-party seems more logical and matches the one you're adding, so this is fine.

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Please correct the macro name in the title/description then I'll merge this.

@DhruvSrivastavaX DhruvSrivastavaX changed the title [lldb][AIX] Introducing ALL_SOURCE macro into driver CMakeLists [lldb][AIX] Introducing _ALL_SOURCE macro into driver CMakeLists Dec 20, 2024
@DhruvSrivastavaX
Copy link
Contributor Author

Hi @DavidSpickett , sure, updated it. Thanks!

@DavidSpickett DavidSpickett merged commit 9a1837f into llvm:main Dec 20, 2024
9 checks passed
@@ -11,6 +11,11 @@ if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-Info.plist")
endif()

if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
remove_definitions("-D_XOPEN_SOURCE=700")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fairly fragile. It may be better to do a -U_XOPEN_SOURCE.

Some comment about why you're undoing the changes here might be in order as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to do a -U_XOPEN_SOURCE

.. which, at least according to my experiments, isn't possible it seems. However, also according to my experiments, remove_definitions doesn't actually remove macros defined by add_compile_definitions (only add_definitions), which brings up another question: Is this actually needed? Would it be sufficient to define _ALL_SOURCE as well?

Copy link
Contributor Author

@DhruvSrivastavaX DhruvSrivastavaX Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, It was added by another team in IBM but I think the intention to add this way was to only utilise the relevant posix standard definitions and avoid any extra un-needed definitions. But then again, some definitions being used in LLDB code, do not come under the _X_OPEN_SOURCE for AIX, in which case we need to use _ALL_SOURCE instead. But yes, I can check if only having add_definitions does not cause any compilation conflicts and update accordingly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The way I'd start is the see if the remove_definitions call is actually doing something (in my experiments, it didn't, but I only tried it on toy programs). If it isn't, then you already have both of these defined, and there's nothing further to check.

That said, if you can get it touch with them, it might be good to check they were trying to achieve, as having different definition in different parts of the program is a recipe for problems. From that comment, it sounds like they had problems building llvm with _ALL_SOURCE, but adding the definition here still requires llvm (at least, parts included by this code) to build in this mode.

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

Successfully merging this pull request may close these issues.

4 participants