Hi Everyone,

This patch restores support for a common cygwin.din file combined with
optional architecture-specific cygwin.din fragments, allowing exported
symbols to vary by target CPU.


  *
The gendef script is extended to read a per-architecture cygwin.din file,
which is appended to the common export list during generation.

This kind of mechanism existed prior to commit 3ba050dfcd1d
("Cygwin: fold common.din and x86_64.din into cygwin.din"), which merged
all exports into a single file when only x86/x86_64 targets were
supported.

With the ongoing introduction of AArch64 support, architecture-specific
export control is again required. The common cygwin.din remains in the
parent directory, while per-architecture files are placed under the
respective arch subdirectories.

Thanks & regards
Thirumalai Nagalingam

In-Lined patch:

iff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
index d543b9b19..a30ceed3b 100644
--- a/winsup/cygwin/Makefile.am
+++ b/winsup/cygwin/Makefile.am
@@ -646,7 +646,9 @@ $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) 
$(LIBSERVER)\
 # cygwin import library
 toolopts=--cpu=@target_cpu@ --ar=@AR@ --as=@AS@ --nm=@NM@ --objcopy=@OBJCOPY@

-$(DEF_FILE): scripts/gendef cygwin.din
+# Architecture-specific .din files
+ARCH_DIN = $(srcdir)/@target_cpu@/cygwin.din
+$(DEF_FILE): scripts/gendef cygwin.din $(wildcard $(ARCH_DIN))
        $(AM_V_GEN)$(srcdir)/scripts/gendef --cpu=@target_cpu@ 
--output-def=$(DEF_FILE) $(srcdir)/cygwin.din

 sigfe.s: $(DEF_FILE) tlsoffsets
diff --git a/winsup/cygwin/aarch64/cygwin.din b/winsup/cygwin/aarch64/cygwin.din
new file mode 100644
index 000000000..927b7411e
--- /dev/null
+++ b/winsup/cygwin/aarch64/cygwin.din
@@ -0,0 +1,4 @@
+# aarch64-specific exports
+# These symbols are only available on aarch64 architecture
+
+# Currently empty - all exports are in common cygwin.din
diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index ddabe8474..45be2d54a 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -33,6 +33,23 @@ while (<>) {
 }
 my @in = cleanup <>;

+# Derive arch-specific cygwin.din relative to the common cygwin.din path
+my $arch_din = $ARGV[0];
+$arch_din =~ s/cygwin\.din$//;
+$arch_din .= "$cpu/cygwin.din";
+
+if (-f $arch_din) {
+    open(ARCH_DIN, '<', $arch_din) or die "Cannot open $arch_din: $!\n";
+    my $in_exports = 0;
+    while (<ARCH_DIN>) {
+        $in_exports = 1 if /^\s*exports$/oi;
+        next unless $in_exports;
+        next if /^\s*exports$/oi;
+        push(@in, cleanup $_);
+    }
+    close(ARCH_DIN);
+}
+
 my %sigfe = ();
 my @data = ();
 my @nosigfuncs = ();
diff --git a/winsup/cygwin/x86_64/cygwin.din b/winsup/cygwin/x86_64/cygwin.din
new file mode 100644
index 000000000..228894623
--- /dev/null
+++ b/winsup/cygwin/x86_64/cygwin.din
@@ -0,0 +1,2 @@
+# x86_64-specific exports
+# These symbols are only available on x86/x64 architectures
--

Attachment: 0001-Cygwin-gendef-support-architecture-specific-cygwin.d.patch
Description: 0001-Cygwin-gendef-support-architecture-specific-cygwin.d.patch

Reply via email to