메뉴
HN
Hacker News 57일 전

또다시 엔디안 논쟁과 이식성 혐오?

IMP
7/10
핵심 요약

해커 뉴스 등에서 벌어지는 '리틀 엔디안의 승리'나 '구식 아키텍처 무용론'과 같이 소프트웨어 이식성을 깎아내리는 적대적 분위기를 비판하는 글입니다. 저자는 다양한 아키텍처(Alpha, MIPS, SPARC 등)가 여전히 교육적, 상업적 가치가 있으며, 실제로 구형 환경에서 리눅스 커널의 보안 취약점이 발견되기도 했음을 사례로 듭니다. 빅 엔디안과 리틀 엔디안 모두 건강한 컴퓨팅 생태계를 위해 필수적이며, 소프트웨어 이식성을 높이는 노력은 단순한 취미가 아닌 실제 문제를 해결하는 중요한 과정임을 강조합니다.

번역된 본문

참고: 이 글은 매우 기술적인 포스트입니다. PowerPC와 ARM의 차이를 모른다면 이 글은 건너뛰어도 좋습니다. 내일이면 다시 일반 대중을 위한 글로 돌아올 테니까요!

오늘 저녁, 내 친구가 실수로 표현의 자유가 넘쳐나는(가상 펜에서 뚝뚝 떨어지는 독설을 느껴보라) 그곳, 해커 뉴스(Hacker News)의 엔디안(Endianness)에 관한 스레드 링크를 나에게 보냈습니다. 나는 이 글을 예전 블로그를 위해 초안을 잡아두었지만, 마음에 드는 결말을 쓰지 못해 출판을 미루고 있었습니다. 그런데 오늘 Zack 덕분에 다시 이 글을 꺼내게 되었습니다. 결말은 새로 다듬었습니다.

사랑하는 독자 여러분, 더 광범위한 오픈소스 소프트웨어 커뮤니티 안에 자리 잡은 이식성(Portability)에 대한 적대감은 저를 지치게 합니다. 특히 프로젝트들이 결국 자신들의 잘못을 깨닫게 될 때가 많다는 점을 생각하면, 이식성을 반대하는 그 진부한 주장들을 반복해서 듣는 것은 정말 피곤한 일입니다. 그래서 제가 자주 듣는 가장 흔한 주장 몇 가지와 그에 대한 반론을 적어보려 합니다.

"구식" 아키텍처에 대하여 제가 듣는 가장 당혹스럽고 빈번한 주장은, 제가 제안(또는 작성)한 포트(Port)가 "오늘날 더 이상 관련 없는" "구식" 아키텍처를 위한 것이라는 것입니다. 리눅스가 지원하는 아키텍처 중 상업적 가치가 전혀 남아있지 않은 것은 DEC Alpha AXP와 Itanium뿐입니다. Itanium은 리눅스 커널 6.7에서 제거되었으며, 이는 예전 블로그에 별도의 글로 다룰 만한 사안이었으므로 여기서 논의에서 제외하겠습니다.

제 생각에 Alpha는 RISC 아키텍처의 핵심 개념을 배우는 데 매우 귀중한 자원입니다. 실제로 RISC-V 팀은 Alpha에서 상당한 영감을 얻었다고 말했으며, 쿼드워드(quadword) 저장과 관련된 몇 가지 기묘한 점만 아니었다면 자체 ISA를 만드는 대신 Alpha를 부활시키려 했을 것입니다. 저는 여전히 Alpha에서 배울 중요한 교훈들이 많다고 생각하며, 그것이 바로 이 아키텍처의 개발이 계속 진행되는 것을 기쁘게 지켜보는 이유입니다! 이는 주로 이를 둘러싼 Gentoo 커뮤니티에 의해 주도되고 있습니다.

MIPS의 경우, 여전히 상업적 지원을 제공받는 제품에서 판매되고 사용되고 있습니다. SPARC는 특허가 없는 개방형 아키텍처로, 그 자체로 매우 가치가 있습니다. PowerPC는 계속 발전하고 있으며, 구형 PPC 시스템은 실제로 RAM 확장이 가능하고 PCI Express 슬롯 등을 갖춘 RISC 워크스테이션을 매우 저렴하게 구할 수 있는 방법입니다. 심지어 Motorola 68000 아키텍처는 오늘날에도 임베디드 환경에서 계속 사용되고 있습니다.

커뮤니티에서 어떤 아키텍처로의 포트를 제안한다면, 그것이 나온 지 4일 된 것이든 40년 된 것이든 관계없이, 그것은 커뮤니티가 해당 아키텍처에서 당신의 소프트웨어를 적극적으로 사용하고 싶어 한다는 뜻입니다. 그렇지 않았다면 아무도 그런 노력을 기울이지 않았을 것입니다. 이런 포트 작업은 어렵고, 나 같은 작성자는 상위(Upstream) 프로젝트가 관심을 가지게 만들려는 것만으로도 이미 고된 싸움을 벌이고 있다는 것을 잘 알고 있습니다. 우리는 건강을 위해서나 일종의 게임처럼 이 일을 하는 것이 아닙니다. 우리가 가진 실제 문제를 해결하기 때문에 이 일을 하는 것입니다.

덧붙여, 저는 "실제" 586(대략 1995년도 인텔 펜티엄)에서 리눅스를 부팅하여 커널에서 실제 보안 버그를 발견하기도 했습니다. 이는 커널의 static_key API를 잘못 사용하여 586에서는 일반 사용자(Non-root)가 보호된 API에 접근할 수 있었지만, 최신 아키텍처에서는 이상 현상이 나타나지 않았던 것입니다. 586의 QEMU 에뮬레이션에서도 조용했는데, 이는 커널 개발자들이 사용하던 QEMU의 CR4 에뮬레이션에 버그가 있었기 때문입니다.

빅 엔디안(Big endian)에 대하여 저는 정기적으로 "리틀 엔디안(little endian)이 이겼다"거나 "빅 엔디안은 더 이상 존재하지 않는다"와 같은 말을 듣습니다. 이것은 틀린 말일 뿐만 아니라, 마치 전쟁처럼 상황을 프레이밍하는 것입니다. 해커 뉴스에서 나온 이런 수사법 때문에 저는 이 글의 초안을 다시 꺼내서 끝맺을 수 있었습니다.

저는 두 가지 유형의 엔디안 모두 건강한 컴퓨팅 생태계를 위해 필수적이라고 굳게 믿으며, 둘 중 하나라도 사라진다면 소프트웨어 엔지니어링을 하고 싶지 않을 것입니다. 더 이상 말할 여지가 없습니다(Full stop). 저는 모든 코드를 빅 엔디안과 리틀 엔디안 시스템 모두에서 테스트하는 것에 대해 매우 완고하기 때문에, 엔디안 정확성은 제 친구들 사이에서 거의 밈(Meme) 수준이 되었습니다.

모르는 분들을 위해 설명하자면, 엔디안은 단순히 컴퓨터가 숫자를 저장하는 방식입니다. 빅 엔디안 시스템은 우리 인간이 하는 방식대로 숫자를 저장합니다. 즉, 가장 큰 자릿수의 숫자가...

원문 보기
원문 보기 (영어)
Note : This is another really technical post. Those who do not know the difference between a PowerPC and an ARM can probably skip this one – we'll be back to general audience posts tomorrow! One of my friends made the mistake this evening of linking me to a thread about endianness on that bastion of free expression, Hacker News. (Feel the shade dripping from my virtual pen.). I had drafted this article for Old Blog, but I never published it because I was never quite satisfied that I had a good ending. Well, today Zach has gotten me on with it. I rewrote the ending. I grow weary, dear reader, of the hostility in the broader open source software community against portability. It is exhausting to hear the same tired arguments against portability, especially when in the end most projects end up realising the errors of their ways. So, here are some of the most common arguments I hear and my rebuttals to them. Against “old” architectures The most disturbing, and frequent, argument that I hear is that whatever port I have suggested (or indeed written) is for an “old” architecture that “is not relevant today”. The only architectures supported by Linux that have no commercial viability left are the DEC Alpha AXP and the Itanium. The Itanium has been removed from the Linux kernel with 6.7, which warranted its own article on Old Blog , so I will remove that one from the discussion. In my opinion, the Alpha is a valuable resource for learning some of the core concepts of a RISC architecture. In fact, the team behind RISC-V said they took a significant amount of inspiration from Alpha, and had it not been for some of the oddities around storing quadwords, they may have tried to resurrect it instead of bringing up their own ISA. I think there are still more valuable lessons to learn from it, which is why I've been quite happy to see development progressing on it! This has been primarily driven by the Gentoo community around it. As for MIPS, it is still sold and used in products with commercial support. SPARC is an open architecture with no patents, which is highly valuable. PowerPC is continuing to evolve, and older PPC systems are a very inexpensive way to obtain a RISC workstation with actual expandable RAM, PCI Express slots, and so on. Even the Motorola 68000 architecture continues to see embedded use today. If the community is offering you a port to an architecture, whether it is 4 days old or 40 years old, that means the community actively wants to use your software on it – otherwise, nobody would put in the effort. Ports like this are hard, and authors like me already know we are fighting an uphill battle just trying to make upstream projects care. We aren’t doing it for our health or as some sort of game. We are doing it because it actually solves a problem we have. I’d also like to point out that I found an actual security bug in the Linux kernel by booting it on a “real” 586 (Intel Pentium, ca 1995). This was caused by an invalid use of the kernel static_key API, which allowed non-root access to a protected API on the 586, but went silent on newer architectures. It was also silent on QEMU emulation of the 586, which is what kernel developers were using, because of buggy CR4 emulation. Against big endian I regularly hear things like “little endian won” or “big endian does not exist any more”. This is not only wrong, but it frames things like a war. It is from this rhetoric on Hacker News that I brought this article draft back out and finished it. I fully believe that both types of endian are necessary for a healthy computing ecosystem, and I wouldn't want to participate in software engineering without either one existing. Full stop. Endian correctness is almost a meme in my friend circle because of how adamant I am about testing all code on both big and little endian systems. For those who don’t know, endianness is simply how the computer stores numbers. Big endian systems store numbers the way us humans do: the largest number is written first. Little endian systems store numbers opposite: the smallest number is written first. Hence, ‘big’ vs ‘little’. I happen to prefer big endian systems in my own development life because they are easier for me to work with, especially reading crash dumps. Big endian systems also catch out some classes of bugs far quicker and easier by “failing fast” vs little endian systems where bugs can lurk. Such classes include invalid type casts which can lead to security bugs. Recently, a memory corruption bug was found in Git. And it was found because the test suite wasn't working properly on a big endian computer. The bug was there in little endian, too, but it wasn't making the test suite crash. I additionally found an invalid memory read/store in Clang that was wrong everywhere, but only crashing on 32-bit big endian hardware. It is usually easy to write code that is endian-safe. Any code that is not endian-safe is poorly written and harder to maintain at best, and possibly obscuring security bugs at worst. Any project maintainer should be jumping for joy when they receive a patch adding a big-endian port of their project, especially if it includes reports that tests pass and the software works. That is the sign of a codebase that has a level of sanity that should not be noteworthy, yet is. Popular architectures that exist today and are exclusively big endian including the System/390 (s390x) mainframe, and the SPARC. Bi-endian architectures, which can be either big or little, include PowerPC (yes, even the Power9 and 10!) and Arm. You can actually boot a Pine A64 and most Raspberry Pi boards in big endian mode, if you need an easy-to-obtain and inexpensive BE CI computer! This is an area of development I hope to focus on eventually. Against 32-bit A lot of arguments against 32-bit are variants on the “old” argument, as most 32-bit architectures predate 64-bit counterparts. RISC-V introduced a 32-bit variant of their ISA, so it isn’t entirely true, but I accept that most 32-bit architectures are older than 64-bit ones. As I’ve noted, “old” does not always equate to “bad” nor “worse”. I’ll take this moment to note that in the developing world, and in poorer communities even in the developed world, many people are getting by with 32-bit ARM systems or Celerons for desktop hardware. There is another argument made against 32-bit architectures, and that is their memory space. You are limited to 4 GB - in most cases, typically a bit less than that. There is something to be said for a lack of 32-bit support in the HPC or machine learning space, considering the massive datasets used there. However, most software programs are not in those spaces. There is no real reason that the 4 GB memory barrier should in any way prevent a Web browser, email client, or program compiler from starting. For that reason, 32-bit support can sometimes be a little harder because it requires optimisation and efficiency, something far too many software programs lack. This has always been a challenge in our industry, and it will continue to be. If someone has managed to make your software work on 32-bit, you should accept that port as it will help ensure your software remains efficient even on 64-bit systems. After all, if every program is required to fit in 4 GB, that means the 32 GB RAM workstation you are spoiled with can run a full 8 programs on it! Think of the multitasking you can do with that sort of power! In summary Open source and Libre software projects are almost always a passion project for those involved. Even when libre software is controlled by commercial interest, the employees working on it feel some sort of personal connection to the software they maintain. Linux didn’t grow as big as it has because of any one single technical quality; it grew big because of the passionate people behind it. In closing, let me reiterate this point so it is crystal clear. If you are a maintainer of a libre software project and you refuse a community port to