Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.14] gh-145010: Fix Python.h compilation with -masm=intel (GH-145011)#145776

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletionsInclude/object.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -199,11 +199,11 @@ _Py_ThreadId(void)
#elif defined(__MINGW32__) && defined(_M_ARM64)
tid = __getReg(18);
#elif defined(__i386__)
__asm__("movl %%gs:0, %0" : "=r" (tid)); // 32-bit always uses GS
__asm__("{movl %%gs:0, %0|mov %0, dword ptr gs:[0]}" : "=r" (tid)); // 32-bit always uses GS
#elif defined(__MACH__) && defined(__x86_64__)
__asm__("movq %%gs:0, %0" : "=r" (tid)); // x86_64 macOSX uses GS
__asm__("{movq %%gs:0, %0|mov %0, qword ptr gs:[0]}" : "=r" (tid)); // x86_64 macOSX uses GS
#elif defined(__x86_64__)
__asm__("movq %%fs:0, %0" : "=r" (tid)); // x86_64 Linux, BSD uses FS
__asm__("{movq %%fs:0, %0|mov %0, qword ptr fs:[0]}" : "=r" (tid)); // x86_64 Linux, BSD uses FS
#elif defined(__arm__) && __ARM_ARCH >= 7
__asm__ ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tid));
#elif defined(__aarch64__) && defined(__APPLE__)
Expand Down
20 changes: 17 additions & 3 deletionsLib/test/test_cppext/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
# gh-91321: Build a basic C++ test extension to check that the Python C API is
# compatible with C++ and does not emit C++ compiler warnings.
importos.path
importplatform
importshlex
importshutil
importsubprocess
Expand DownExpand Up@@ -28,13 +29,16 @@
classBaseTests:
TEST_INTERNAL_C_API=False

defcheck_build(self,extension_name,std=None,limited=False):
defcheck_build(self,extension_name,std=None,limited=False,
extra_cflags=None):
venv_dir='env'
withsupport.setup_venv_with_pip_setuptools(venv_dir)aspython_exe:
self._check_build(extension_name,python_exe,
std=std,limited=limited)
std=std,limited=limited,
extra_cflags=extra_cflags)

def_check_build(self,extension_name,python_exe,std,limited):
def_check_build(self,extension_name,python_exe,std,limited,
extra_cflags=None):
pkg_dir='pkg'
os.mkdir(pkg_dir)
shutil.copy(SETUP,os.path.join(pkg_dir,os.path.basename(SETUP)))
Expand All@@ -48,6 +52,8 @@ def run_cmd(operation, cmd):
env['CPYTHON_TEST_LIMITED']='1'
env['CPYTHON_TEST_EXT_NAME']=extension_name
env['TEST_INTERNAL_C_API']=str(int(self.TEST_INTERNAL_C_API))
ifextra_cflags:
env['CPYTHON_TEST_EXTRA_CFLAGS']=extra_cflags
ifsupport.verbose:
print('Run:',' '.join(map(shlex.quote,cmd)))
subprocess.run(cmd,check=True,env=env)
Expand DownExpand Up@@ -116,6 +122,14 @@ def test_build_cpp11(self):
deftest_build_cpp14(self):
self.check_build('_testcpp14ext',std='c++14')

# Test that headers compile with Intel asm syntax, which may conflict
# with inline assembly in free-threading headers that use AT&T syntax.
@unittest.skipIf(support.MS_WINDOWS,"MSVC doesn't support -masm=intel")
@unittest.skipUnless(platform.machine()in ('x86_64','i686','AMD64'),
"x86-specific flag")
deftest_build_intel_asm(self):
self.check_build('_testcppext_asm',extra_cflags='-masm=intel')


classTestInteralCAPI(BaseTests,unittest.TestCase):
TEST_INTERNAL_C_API=True
Expand Down
4 changes: 4 additions & 0 deletionsLib/test/test_cppext/setup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,10 @@ def main():
ifinternal:
cppflags.append('-DTEST_INTERNAL_C_API=1')

extra_cflags=os.environ.get("CPYTHON_TEST_EXTRA_CFLAGS","")
ifextra_cflags:
cppflags.extend(shlex.split(extra_cflags))

# On Windows, add PCbuild\amd64\ to include and library directories
include_dirs= []
library_dirs= []
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
Use GCC dialect alternatives for inline assembly in ``object.h`` so that the
Python headers compile correctly with ``-masm=intel``.
Loading

[8]ページ先頭

©2009-2026 Movatter.jp